Skip to content

Commit

Permalink
Bug fix with 'AutoUpdateSpecialTeams', only non-starting WR, RB shoul…
Browse files Browse the repository at this point in the history
…d be returning kicks/punts

Made changes to allow cross-saving between PS2 and Xbox files.
  • Loading branch information
BAD-AL committed Nov 9, 2020
1 parent 72b1f2b commit 660252e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
39 changes: 25 additions & 14 deletions GamesaveTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,9 +1013,9 @@ private void AutoUpdateSpecialTeams(string team)
int teamIndex = GetTeamIndex(team);
int teamPlayerPointersStart = teamIndex * cTeamDiff + m49ersPlayerPointersStart;
List<int> playerIndexes = GetPlayerIndexesForTeam(team);
//GetPlayerPositionDepth
byte fast1 = 0;
byte fast2 = 0;

byte fast1 = (byte) (playerIndexes.Count - 1);
byte fast2 = (byte) (playerIndexes.Count - 2);
byte center = 0;
int speedTest1 = 0;
int speedTest2 = 0;
Expand All @@ -1024,18 +1024,21 @@ private void AutoUpdateSpecialTeams(string team)
for(byte i = (byte)(playerIndexes.Count-1) ; i > 0 ; i--)
{
playerPosition = GetPlayerPosition(playerIndexes[i]) + ",";
if ("CB,WR,RB,".IndexOf(playerPosition) > -1)
if (",WR,RB,".IndexOf(playerPosition) > -1)
{
Int32.TryParse(GetAttribute(playerIndexes[i], PlayerOffsets.Speed), out speedTest1);
Int32.TryParse(GetAttribute(playerIndexes[fast1], PlayerOffsets.Speed), out speedTest2);
if (speedTest1 > speedTest2 && GetPlayerPositionDepth(playerIndexes[i]) > 2)
{
fast2 = fast1;
fast1 = i;
}
else if (fast2 == 0)
if (!IsStarter((byte)GetPlayerPositionDepth(playerIndexes[i])))
{
fast2 = i;
if (speedTest1 > speedTest2)
{
fast2 = fast1;
fast1 = i;
}
else if (fast2 == 0)
{
fast2 = i;
}
}
}
else if (playerPosition == "C," && center == 0)
Expand All @@ -1049,6 +1052,14 @@ private void AutoUpdateSpecialTeams(string team)
SetByte(teamPlayerPointersStart + (int)SpecialTeamer.LS, center);
}

private bool IsStarter(byte depth)
{
bool retVal = false;
if (depth == 0 || depth == 0x60 || depth == 0x10)
retVal = true;
return retVal;
}

/// <summary>
/// Returns the given team's special team set like:
/// KR1,RB3
Expand Down Expand Up @@ -1240,9 +1251,9 @@ public void SaveFile(string fileName)
}
Console.WriteLine("# Data successfully written to file: {0}.", fileName);
}
else if (fileName.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase) && mZipFile.Length > 4)
else if (fileName.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase) )
{
if( mZipFile != fileName)
if (!String.IsNullOrEmpty(mZipFile) && mZipFile != fileName)
File.Copy(mZipFile, fileName, true);
string tmpFile = Path.GetTempFileName();
File.WriteAllBytes(tmpFile, GameSaveData);
Expand All @@ -1256,7 +1267,7 @@ public void SaveFile(string fileName)
}
else if (fileName.EndsWith(".max", StringComparison.InvariantCultureIgnoreCase) )
{
if (mPS2SaveFile != fileName)
if (!String.IsNullOrEmpty( mPS2SaveFile) && mPS2SaveFile != fileName)
File.Copy(mPS2SaveFile, fileName, true);
PS2FileHelper helper = null;

Expand Down
3 changes: 2 additions & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
// by using the '*' as shown below:
//[assembly: AssemblyVersion("0.9.0.1")] // bug fixes
//[assembly: AssemblyVersion("0.9.0.2")] // Face Form improvements
[assembly: AssemblyVersion("0.9.0.8")] // Face form scrollbar (paging) fix; List Depth charts (better) from Debug Dialog ; Better Error handling in main form ; Check Special teams (menu item)
[assembly: AssemblyVersion("0.9.0.9")] //Bug fix for SutoUpdate_ST; allow cross save between XBOX & PS2 save files.
//[assembly: AssemblyVersion("0.9.0.8")] // Face form scrollbar (paging) fix; List Depth charts (better) from Debug Dialog ; Better Error handling in main form ; Check Special teams (menu item)
//[assembly: AssemblyVersion("0.9.0.7")] // check faces, dreads menus; SearchTextBox.CopyAll; resetKey menuItem; autoSelect apperance (when skills are blank);
//[assembly: AssemblyVersion("0.9.0.6")] // Updated menus
//[assembly: AssemblyVersion("0.9.0.5")] // Updated links...
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ When working with files that have been modified by Flying Finn's NFL2K5 editor t
22. Check skin/face & Dreads menu items
23. SearchTextBox.CopyAll context menu item
24. Reset key menu item.
25. Cross-save between Xbox and PS2 files.

### Next features:
* Editing coaches (currently limited support)
Expand Down
Binary file modified bin/Debug/NFL2K5Tool.exe
Binary file not shown.

0 comments on commit 660252e

Please sign in to comment.