Summer 19 Version B

master
Noteperson 3 years ago
commit 49926fa1b2
  1. 237
      4ccEditor.vcproj
  2. BIN
      4cc_logo.bmp
  3. BIN
      4cc_med.ico
  4. BIN
      4cc_sm.ico
  5. 641
      aatf.cpp
  6. 462
      comparator.cpp
  7. 40
      crypt.cpp
  8. 84
      crypt.h
  9. 698
      editor.h
  10. 5965
      main.cpp
  11. 968
      pes16.cpp
  12. 979
      pes17.cpp
  13. 994
      pes18.cpp
  14. 919
      pstdint.h
  15. 406
      resource.h
  16. 165
      resource.rc

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="4ccEditor"
ProjectGUID="{ACD373D6-744B-4ADF-8E7B-41492B847A4B}"
RootNamespace="My4ccEditor"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\aatf.cpp"
>
</File>
<File
RelativePath=".\comparator.cpp"
>
</File>
<File
RelativePath=".\crypt.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\pes16.cpp"
>
</File>
<File
RelativePath=".\pes17.cpp"
>
</File>
<File
RelativePath=".\pes18.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\crypt.h"
>
</File>
<File
RelativePath=".\editor.h"
>
</File>
<File
RelativePath=".\pstdint.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\resource.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1,641 @@
#include <string>
#include <sstream>
#include "editor.h"
#include "resource.h"
#ifndef UNICODE
typedef std::string tstring;
typedef std::stringstream tstringstream;
#else
typedef std::wstring tstring;
typedef std::wstringstream tstringstream;
#endif
void aatf_single(HWND hAatfbox, int pesVersion, int teamSel, player_entry* gplayers, team_entry* gteams, int gnum_players)
{
player_entry player;
tstring msgOut;
msgOut+=_T("Team: ");
msgOut+=gteams[teamSel].name;
msgOut+=_T("\r\n");
int manletBonus = 5;
int ii,jj;
int numGK = 0;
//Player ratings
int numReg = 0;
int numSilver = 0;
int numGold = 0;
//Height brackets
int numGiant = 0;
int numTall = 0;
int numMid = 0;
int numManlet = 0;
bool usingRed = false;
int errorTot = 0;
for(ii=0; ii<gteams[teamSel].num_on_team; ii++)
{
//Find each player on team
for(jj=0; jj<gnum_players; jj++)
{
if(gplayers[jj].id == gteams[teamSel].players[ii])
{
player = gplayers[jj];
break;
}
}
msgOut+=_T("\x2022 Checking ");
msgOut+=player.name;
msgOut+=_T("\r\n");
tstringstream errorMsg;
int cardCount = 0;
int cardMod = 0;
bool hasTrick = false;
int targetRate = 0, targetRate2 = 0;
int rating = player.drib;
rating = max(player.gk, rating);
rating = max(player.finish, rating);
rating = max(player.lowpass, rating);
rating = max(player.loftpass, rating);
rating = max(player.header, rating);
rating = max(player.swerve, rating);
rating = max(player.catching, rating);
rating = max(player.clearing, rating);
rating = max(player.reflex, rating);
rating = max(player.body_ctrl, rating);
if(pesVersion!=16) rating = max(player.phys_cont, rating); //Not in 16
rating = max(player.kick_pwr, rating);
rating = max(player.exp_pwr, rating);
rating = max(player.ball_ctrl, rating);
rating = max(player.ball_win, rating);
rating = max(player.jump, rating);
rating = max(player.cover, rating);
rating = max(player.place_kick, rating);
rating = max(player.stamina, rating);
rating = max(player.speed, rating);
if(player.injury+1 != 3)
{
errorTot++;
errorMsg << _T("Injury resist is ") << player.injury+1 << _T(", should be 3; ");
}
//Check if registered pos has playable set to A
if(player.reg_pos == 12 && player.play_pos[0] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 11 && player.play_pos[1] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 10 && player.play_pos[3] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 9 && player.play_pos[2] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 8 && player.play_pos[4] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 7 && player.play_pos[8] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 6 && player.play_pos[7] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 5 && player.play_pos[6] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 4 && player.play_pos[5] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 3 && player.play_pos[11] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 2 && player.play_pos[10] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 1 && player.play_pos[9] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
else if(player.reg_pos == 0)
{
numGK++;
if(player.play_pos[12] != 2)
{
errorTot++;
errorMsg << _T("Doesn't have A in registered position; ");
}
}
//Count A positions
int countA = 0;
for(jj=0;jj<13;jj++)
{
if(player.play_pos[jj] > 0)
countA++;
}
//If 2 A's, 1 card less
if(countA > 1)
{
if(player.play_pos[12] == 2) //Can't have GK as second A
{
errorTot++;
errorMsg << _T("Has GK as second A position; ");
}
else
cardMod--;
//If 3 or more non-C's, error
if(countA > 2)
{
errorTot++;
errorMsg << _T("Has more than 2 A positions; ");
}
}
//Count cards
for(jj=0;jj<28;jj++)
{
if(player.play_skill[jj])
{
cardCount++;
//Captain gets free captaincy card
if(jj==25 && player.id == gteams[teamSel].players[gteams[teamSel].captain_ind])
cardMod++;
//One trick card may be free, check if has any
if(jj<6 || jj==16)
hasTrick = true;
}
}
for(jj=0;jj<7;jj++)
{
if(player.com_style[jj])
cardCount++;
}
if(player.height <= 175)
{
numManlet++;
cardMod++; //Manlets get a bonus card
}
else if(player.height == 180)
numMid++;
else if(player.height == 185)
numTall++;
//else if(player.height == 189 && player.reg_pos == 0) //GK
// numTall++;
else if(player.height == 194)
numGiant++;
else
{
errorTot++;
errorMsg << _T("Illegal height (") << player.height << _T(" cm); ");
}
if(player.age<15 || player.age>50)
{
errorTot++;
errorMsg << _T("Age out of range (15,50); ");
}
if(player.weight<max(30,player.height-129) || player.weight>(player.height-81))
{
errorTot++;
errorMsg << _T("Weight out of range (") << max(30,player.height-129) << _T(",") << player.height-81 << _T("); ");
}
if(rating < 91)
{
numReg++;
targetRate = 77;
targetRate2 = 72;
if(player.height >= 180)
{
if(player.weak_use+1 > 2)
{
errorTot++;
errorMsg << _T("Weak foot usage > 2; ");
}
if(player.weak_acc+1 > 2)
{
errorTot++;
errorMsg << _T("Weak foot accuracy > 2; ");
}
}
if(player.form+1 != 4)
{
errorTot++;
errorMsg << _T("Form is ") << player.form+1 << _T(", should be 4; ");
}
if(player.reg_pos == 0) //GK gets 1 card, height capped to 185cm
{
if(cardCount > 1 + cardMod)
{
errorTot++;
errorMsg << _T("Has ") << cardCount << _T(" cards, only allowed ") << 1 + cardMod << _T("; ");
}
if(player.height > 185)
{
errorTot++;
errorMsg << _T("GK height over 185cm; ");
}
}
else if(cardCount > 2 + cardMod)
{
errorTot++;
errorMsg << _T("Has ") << cardCount << _T(" cards, only allowed ") << 2 + cardMod << _T("; ");
}
if(player.reg_pos == 0) //GK gets target rate is 72
{
targetRate = 72;
if(player.height <= 175)
{
targetRate += manletBonus;
targetRate2 += manletBonus;
}
}
else if(rating != targetRate)
{
if(rating != targetRate+manletBonus || player.height > 175)
{
errorTot++;
errorMsg << _T("Illegal Ability scores; ");
}
else
{
usingRed = true;
targetRate += manletBonus;
targetRate2 += manletBonus;
}
}
}
else if(rating < 99)
{
numSilver++;
targetRate = 91;
targetRate2 = 91;
if(numSilver>2)
{
errorTot++;
errorMsg << _T("Already has 2 Silver medals; ");
}
if(player.form+1 != 8)
{
errorTot++;
errorMsg << _T("Form is ") << player.form+1 << _T(", should be 8; ");
}
if(player.reg_pos == 0) //Medals can't be GK
{
errorTot++;
errorMsg << _T("Medals cannot play as GK; ");
}
if(player.height > 185) //Medals can't be HA
{
errorTot++;
errorMsg << _T("Medals cannot be taller than 185cm; ");
}
if(hasTrick) //Free trick card for medals
cardMod++;
if(player.play_skill[11]) //Free FTS for medals
cardMod++;
if(cardCount > 3 + cardMod)
{
errorTot++;
errorMsg << _T("Has ") << cardCount << _T(" cards, only allowed ") << 3 + cardMod << _T("; ");
}
if(rating != targetRate)
{
errorTot++;
errorMsg << _T("Illegal Ability scores; ");
}
}
else //rating == 99
{
numGold++;
targetRate = 99;
targetRate2 = 99;
if(numGold>2)
{
errorTot++;
errorMsg << _T("Already has 2 Gold medals; ");
}
if(player.form+1 != 8)
{
errorTot++;
errorMsg << _T("Form is ") << player.form+1 << _T(", should be 8; ");
}
if(player.reg_pos == 0) //Medals can't be GK
{
errorTot++;
errorMsg << _T("Medals cannot play as GK; ");
}
if(player.height > 185) //Medals can't be HA
{
errorTot++;
errorMsg << _T("Medals cannot be taller than 185cm; ");
}
if(hasTrick)
cardMod++;
if(player.play_skill[11]) //Free FTS for medals
cardMod++;
if(cardCount > 4 + cardMod)
{
errorTot++;
errorMsg << _T("Has ") << cardCount << _T(" cards, only allowed ") << 4 + cardMod << _T("; ");
}
if(rating != targetRate)
{
errorTot++;
errorMsg << _T("Illegal Ability scores; ");
}
}
if(player.drib != targetRate)
{
errorTot++;
errorMsg << _T("Dribbling is ") << player.drib << _T(", should be ") << targetRate << _T("; ");
}
if(player.gk != targetRate)
{
errorTot++;
errorMsg << _T("Goalkeeping is ") << player.gk << _T(", should be ") << targetRate << _T("; ");
}
if(player.finish != targetRate)
{
errorTot++;
errorMsg << _T("Finishing is ") << player.finish << _T(", should be ") << targetRate << _T("; ");
}
if(player.lowpass != targetRate)
{
errorTot++;
errorMsg << _T("Low Pass is ") << player.lowpass << _T(", should be ") << targetRate << _T("; ");
}
if(player.loftpass != targetRate)
{
errorTot++;
errorMsg << _T("Lofted Pass is ") << player.loftpass << _T(", should be ") << targetRate << _T("; ");
}
if(player.header != targetRate)
{
errorTot++;
errorMsg << _T("Header is ") << player.header << _T(", should be ") << targetRate << _T("; ");
}
if(player.swerve != targetRate)
{
errorTot++;
errorMsg << _T("Swerve is ") << player.swerve << _T(", should be ") << targetRate << _T("; ");
}
if(player.catching != targetRate)
{
errorTot++;
errorMsg << _T("Catching is ") << player.catching << _T(", should be ") << targetRate << _T("; ");
}
if(player.clearing != targetRate)
{
errorTot++;
errorMsg << _T("Clearing is ") << player.clearing << _T(", should be ") << targetRate << _T("; ");
}
if(player.reflex != targetRate)
{
errorTot++;
errorMsg << _T("Reflexes is ") << player.reflex << _T(", should be ") << targetRate << _T("; ");
}
if(player.body_ctrl != targetRate)
{
errorTot++;
errorMsg << _T("Body Control is ") << player.body_ctrl << _T(", should be ") << targetRate << _T("; ");
}
if(player.phys_cont != targetRate && pesVersion!=16) //Not in 16
{
errorTot++;
errorMsg << _T("Physical Contact is ") << player.phys_cont << _T(", should be ") << targetRate << _T("; ");
}
if(player.kick_pwr != targetRate)
{
errorTot++;
errorMsg << _T("Kicking Power is ") << player.kick_pwr << _T(", should be ") << targetRate << _T("; ");
}
if(player.exp_pwr != targetRate2)
{
errorTot++;
errorMsg << _T("Explosive Power is ") << player.exp_pwr << _T(", should be ") << targetRate2 << _T("; ");
}
if(player.ball_ctrl != targetRate)
{
errorTot++;
errorMsg << _T("Ball Control is ") << player.ball_ctrl << _T(", should be ") << targetRate << _T("; ");
}
if(player.ball_win != targetRate2)
{
errorTot++;
errorMsg << _T("Ball winning is ") << player.ball_win << _T(", should be ") << targetRate2 << _T("; ");
}
if(player.jump != targetRate)
{
errorTot++;
errorMsg << _T("Jump is ") << player.jump << _T(", should be ") << targetRate << _T("; ");
}
if(player.cover != targetRate)
{
errorTot++;
errorMsg << _T("Coverage is ") << player.cover << _T(", should be ") << targetRate << _T("; ");
}
if(player.place_kick != targetRate)
{
errorTot++;
errorMsg << _T("Place Kicking is ") << player.place_kick << _T(", should be ") << targetRate << _T("; ");
}
if(player.stamina != targetRate)
{
errorTot++;
errorMsg << _T("Stamina is ") << player.stamina << _T(", should be ") << targetRate << _T("; ");
}
if(player.speed != targetRate)
{
errorTot++;
errorMsg << _T("Speed is ") << player.speed << _T(", should be ") << targetRate << _T("; ");
}
if(player.atk > targetRate)
{
errorTot++;
errorMsg << _T("Attacking Prowess is ") << player.atk << _T(", should be ") << targetRate << _T(" or less; ");
}
if(player.def > targetRate2)
{
errorTot++;
errorMsg << _T("Defensive Prowess is ") << player.def << _T(", should be ") << targetRate2 << _T(" or less; ");
}
if(errorMsg.rdbuf()->in_avail())
{
errorMsg << _T("\r\n");
msgOut+=_T("\t");
msgOut+=errorMsg.str();
}
}
//Team level errors
int diff;
tstringstream errorMsg;
//Check heights
if(!usingRed) //Using Green height system
{
msgOut+=_T("Using Green height system\r\n");
if(diff = 5 - numGiant)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numGiant << _T("/5 194cm players; ");
}
if(diff = 5 - numTall)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numTall << _T("/5 185/9cm players; ");
}
if(diff = 7 - numMid)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numMid << _T("/7 180cm players; ");
}
if(diff = 6 - numManlet)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numManlet << _T("/6 175cm players; ");
}
}
else //Using Red height system
{
msgOut+=_T("Using Red height system\r\n");
if(diff = numGiant)
{
errorTot += diff;
errorMsg << _T("Has ") << numGiant << _T("/0 194cm players; ");
}
if(diff = 10 - numTall)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numTall << _T("/10 185/9cm players; ");
}
if(diff = 7 - numMid)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numMid << _T("/7 180cm players; ");
}
if(diff = 6 - numManlet)
{
if(diff>0)
{
errorTot += diff;
}
else
{
errorTot -= diff;
}
errorMsg << _T("Has ") << numManlet << _T("/6 175cm players; ");
}
}
if(errorMsg.rdbuf()->in_avail())
{
errorMsg << _T("\r\n");
msgOut+=errorMsg.str();
errorMsg.clear();
errorMsg.str(tstring());
}
//Check ability stats
if(numReg!=19)
{
errorTot++;
errorMsg << _T("Number of Regular players is ") << numReg << _T(", should be 19; ");
}
if(numSilver!=2)
{
errorTot++;
errorMsg << _T("Number of Silver medals is ") << numSilver << _T(", should be 2; ");
}
if(numGold!=2)
{
errorTot++;
errorMsg << _T("Number of Gold medals is ") << numGold << _T(", should be 2; ");
}
if(errorMsg.rdbuf()->in_avail())
errorMsg << _T("\r\n");
errorMsg << _T("\r\nErrors: ") << errorTot << _T("\r\n");
msgOut+=errorMsg.str();
SetWindowText(GetDlgItem(hAatfbox, IDT_AATFOUT), msgOut.c_str());
if(errorTot)
SendDlgItemMessage(hAatfbox, IDB_AATFOK, WM_SETTEXT, 0, (LPARAM) _T("Yep. This one's going in my cringe compilation."));
else
SendDlgItemMessage(hAatfbox, IDB_AATFOK, WM_SETTEXT, 0, (LPARAM) _T("BASED AND RULESPILLED"));
}

@ -0,0 +1,462 @@
#include <string>
#include <sstream>
#include "editor.h"
//#include <Commdlg.h>
#include "crypt.h"
#include "resource.h"
#ifndef UNICODE
typedef std::string tstring;
typedef std::stringstream tstringstream;
#else
typedef std::wstring tstring;
typedef std::wstringstream tstringstream;
#endif
void compare_data_handler(const TCHAR*, int);
tstring do_comparison(int, player_entry*, int, team_entry*, int);
tstring compare_single_team(int, int, player_entry*, int, team_entry*);
void *hc_descriptor;
player_entry* c_players = NULL;
team_entry* c_teams = NULL;
int c_num_players, c_num_teams;
extern HINSTANCE hPesDecryptDLL; //Handle to libpesXdecrypter.dll
extern pf_createFileDescriptorOld createFileDescriptorOld;
extern pf_createFileDescriptorNew createFileDescriptorNew;
extern pf_destroyFileDescriptorOld destroyFileDescriptorOld;
extern pf_destroyFileDescriptorNew destroyFileDescriptorNew;
extern pf_decryptWithKeyOld decryptWithKeyOld;
extern pf_decryptWithKeyNew decryptWithKeyNew;
extern pf_encryptWithKeyOld encryptWithKeyOld;
extern pf_encryptWithKeyNew encryptWithKeyNew;
void save_comparator(HWND hCompareBox, int nPesVersion, player_entry* gplayers, int gnum_players, team_entry* gteams, int gnum_teams, TCHAR *cs_file_name)
{
// //Open dialog box to get file path
// OPENFILENAME ofn;
// TCHAR cs_file_name[MAX_PATH];
// TCHAR cs_open_title[40];
//
// _stprintf_s(cs_open_title, 40, _T("Select PES%d EDIT file for comparison"), nPesVersion);
//
// ZeroMemory(&ofn, sizeof(ofn));
//
// ofn.lStructSize = sizeof(OPENFILENAME);
// ofn.hwndOwner = hCompareBox;
//// ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
// ofn.lpstrFile = cs_file_name;
// ofn.nMaxFile = MAX_PATH;
// ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
// ofn.lpstrTitle = cs_open_title;
//
// if(GetOpenFileName(&ofn))
{
compare_data_handler(cs_file_name, nPesVersion);
//Do comparison between players, teams
tstring result = do_comparison(nPesVersion, gplayers, gnum_players, gteams, gnum_teams);
if(result.empty()) result = _T("No changes found!");
//Display result in dialog box
SetWindowText(GetDlgItem(hCompareBox, IDT_AATFOUT), result.c_str());
//Cleanup should go here...
if(hc_descriptor)
{
if(nPesVersion==18)
destroyFileDescriptorNew((FileDescriptorNew*)hc_descriptor);
else
destroyFileDescriptorOld((FileDescriptorOld*)hc_descriptor);
hc_descriptor = NULL;
}
if(c_players)
{
delete[] c_players;
c_players = NULL;
}
if(c_teams)
{
delete[] c_teams;
c_teams = NULL;
}
}
}
void compare_data_handler(const TCHAR *pcs_file_name, int nPesVersion)
{
int ii, current_byte, appearance_byte;
const uint8_t* pMasterKey;
if(hc_descriptor)
{
if(nPesVersion==18)
destroyFileDescriptorNew((FileDescriptorNew*)hc_descriptor);
else
destroyFileDescriptorOld((FileDescriptorOld*)hc_descriptor);
hc_descriptor = NULL;
}
if(c_players)
{
delete[] c_players;
c_players = NULL;
}
if(c_teams)
{
delete[] c_teams;
c_teams = NULL;
}
if(nPesVersion==16)
{
hc_descriptor = (void*)createFileDescriptorOld();
pMasterKey = (const uint8_t*)GetProcAddress(hPesDecryptDLL, "MasterKeyPes16");
uint8_t *pfin = readFile(pcs_file_name, NULL);
decryptWithKeyOld((FileDescriptorOld*)hc_descriptor, pfin, reinterpret_cast<const char*>(pMasterKey));
//get number of player, team entries
c_num_players = ((FileDescriptorOld*)hc_descriptor)->data[0x34];
c_num_players += (((FileDescriptorOld*)hc_descriptor)->data[0x35])*256;
c_num_teams = ((FileDescriptorOld*)hc_descriptor)->data[0x38];
c_num_teams += (((FileDescriptorOld*)hc_descriptor)->data[0x39])*256;
//place player info+appearance entries into array of structs
current_byte = 0x4C;
appearance_byte = 0x2AB9CC;
c_players = new player_entry[c_num_players];
for(ii=0;ii<c_num_players;ii++)
{
fill_player_entry16(c_players[ii], current_byte, hc_descriptor);
fill_appearance_entry16(c_players[ii], appearance_byte, hc_descriptor);
}
//place team entries into array of structs
current_byte = 0x46310C;
c_teams = new team_entry[c_num_teams];
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_ids16(c_teams[ii], current_byte, hc_descriptor);
}
current_byte = 0x4FCC6C;
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_rosters16(current_byte, hc_descriptor, c_teams, c_num_teams);
}
current_byte = 0x51F814;
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_tactics16(current_byte, hc_descriptor, c_teams, c_num_teams);
}
}
else if(nPesVersion==17)
{
hc_descriptor = (void*)createFileDescriptorOld();
pMasterKey = (const uint8_t*)GetProcAddress(hPesDecryptDLL, "MasterKeyPes17");
uint8_t *pfin = readFile(pcs_file_name, NULL);
decryptWithKeyOld((FileDescriptorOld*)hc_descriptor, pfin, reinterpret_cast<const char*>(pMasterKey));
//get number of player, team entries
c_num_players = ((FileDescriptorOld*)hc_descriptor)->data[0x5C];
c_num_players += (((FileDescriptorOld*)hc_descriptor)->data[0x5D])*256;
c_num_teams = ((FileDescriptorOld*)hc_descriptor)->data[0x60];
c_num_teams += (((FileDescriptorOld*)hc_descriptor)->data[0x61])*256;
//place player info+appearance entries into array of structs
current_byte = 0x78;
c_players = new player_entry[c_num_players];
for(ii=0;ii<c_num_players;ii++)
{
fill_player_entry17(c_players[ii], current_byte, hc_descriptor);
}
//place team entries into array of structs
current_byte = 0x3C3E58;
c_teams = new team_entry[c_num_teams];
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_ids17(c_teams[ii], current_byte, hc_descriptor);
}
current_byte = 0x475A90;
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_rosters17(current_byte, hc_descriptor, c_teams, c_num_teams);
}
current_byte = 0x490640;
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_tactics17(current_byte, hc_descriptor, c_teams, c_num_teams);
}
}
else
{
hc_descriptor = (void*)createFileDescriptorNew();
pMasterKey = (const uint8_t*)GetProcAddress(hPesDecryptDLL, "MasterKeyPes18");
uint8_t *pfin = readFile(pcs_file_name, NULL);
//try
//{
decryptWithKeyNew((FileDescriptorNew*)hc_descriptor, pfin, reinterpret_cast<const char*>(pMasterKey));
//}
//catch(...)
//{
// MessageBox(ghw_main, _T("Bad file, cannot load."), _T("Error!"), MB_ICONEXCLAMATION | MB_OK);
// return;
//}
//get number of player, team entries
c_num_players = ((FileDescriptorNew*)hc_descriptor)->data[96];
c_num_players += (((FileDescriptorNew*)hc_descriptor)->data[97])*256;
c_num_teams = ((FileDescriptorNew*)hc_descriptor)->data[100];
c_num_teams += (((FileDescriptorNew*)hc_descriptor)->data[101])*256;
//place player info+appearance entries into array of structs
current_byte = 0x7C;
c_players = new player_entry[c_num_players];
for(ii=0;ii<c_num_players;ii++)
{
fill_player_entry18(c_players[ii], current_byte, hc_descriptor);
}
//place team entries into array of structs
current_byte = 0x3C3E5C;
c_teams = new team_entry[c_num_teams];
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_ids18(c_teams[ii], current_byte, hc_descriptor);
}
current_byte = 0x46FF54;
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_rosters18(current_byte, hc_descriptor, c_teams, c_num_teams);
}
current_byte = 0x488B74;
for(ii=0;ii<c_num_teams;ii++)
{
fill_team_tactics18(current_byte, hc_descriptor, c_teams, c_num_teams);
}
}
//Find, hide loose players
int jj, kk;
for(ii=0;ii<c_num_players;ii++)
{
bool match = false;
for(jj=0;jj<c_num_teams;jj++)
{
for(kk=0;kk<32;kk++)
{
if(c_teams[jj].players[kk]==c_players[ii].id)
{
match = true;
break;
}
}
if(match)
{
c_players[ii].team_ind = jj;
c_players[ii].team_lineup_ind = kk;
break;
}
}
if(c_players[ii].team_ind < 0)
{
c_players[ii].b_show = false;
}
}
//
}
tstring do_comparison(int nPesVersion, player_entry* gplayers, int gnum_players, team_entry* gteams, int gnum_teams)
{
int ii,num_teams;
tstring msgOut=_T("");
tstringstream errorMsg;
if(gnum_teams!=c_num_teams)
{
errorMsg << _T("WARNING: Number of teams differs, A: ") << gnum_teams <<_T(", B: ") << c_num_teams << _T("\r\n");
num_teams = min(gnum_teams, c_num_teams);
msgOut+=errorMsg.str();
}
else
num_teams = gnum_teams;
for(ii=0;ii<num_teams;ii++)
{
msgOut += compare_single_team(nPesVersion, ii, gplayers, gnum_players, gteams);
}
return msgOut;
}
tstring compare_single_team(int pesVersion, int teamSel, player_entry* gplayers, int gnum_players, team_entry* gteams)
{
player_entry playerA, playerB;
tstring msgOut = _T("Changes for ");
msgOut += gteams[teamSel].name;
msgOut += _T(":\r\n");
tstringstream errorMsg;
//msgOut+=_T("Team: ");
//msgOut+=gteams[teamSel].name;
//msgOut+=_T("\r\n");
int num_on_team;
if(gteams[teamSel].num_on_team != c_teams[teamSel].num_on_team)
{
errorMsg << _T("WARNING: Size of squad differs, A: ") << gteams[teamSel].num_on_team <<_T(", B: ") <<
c_teams[teamSel].num_on_team << _T("\r\n");
num_on_team = min(gteams[teamSel].num_on_team, c_teams[teamSel].num_on_team);
}
else
num_on_team = gteams[teamSel].num_on_team;
//Compare captains
for(int ii=0; ii<num_on_team; ii++)
{
//Find each player on team
for(int jj=0; jj<gnum_players; jj++)
{
if(gplayers[jj].id == gteams[teamSel].players[ii])
{
playerA = gplayers[jj];
break;
}
}
for(int jj=0; jj<c_num_players; jj++)
{
if(c_players[jj].id == c_teams[teamSel].players[ii])
{
playerB = c_players[jj];
break;
}
}
if(playerA == playerB) continue;
errorMsg << _T(" Player ") << ii+1 << _T(" (PID ") << playerA.id << _T(")\r\n");
if(wcscmp(playerA.name, playerB.name)!=0)
errorMsg << _T("\tName: ") << playerA.name <<_T(" / ") << playerB.name <<_T("\r\n");
if(strcmp(playerA.shirt_name, playerB.shirt_name)!=0)
errorMsg << _T("\tShirt Name: ") << playerA.shirt_name <<_T(" / ") << playerB.shirt_name <<_T("\r\n");
if(playerA.id!=playerB.id)
errorMsg << _T("\tPlayerID: ") << playerA.id <<_T(" / ") << playerB.id <<_T("\r\n");
if(playerA.age!=playerB.age)
errorMsg << _T("\tAge: ") << (int)playerA.age <<_T(" / ") << (int)playerB.age <<_T("\r\n");
if(playerA.height!=playerB.height)
errorMsg << _T("\tHeight: ") << (int)playerA.height <<_T(" / ") << (int)playerB.height <<_T("\r\n");
if(playerA.weight!=playerB.weight)
errorMsg << _T("\tWeight: ") << (int)playerA.weight <<_T(" / ") << (int)playerB.weight <<_T("\r\n");
if(playerA.atk!=playerB.atk)
errorMsg << _T("\tatk: ") << (int)playerA.atk <<_T(" / ") << (int)playerB.atk <<_T("\r\n");
if(playerA.ball_ctrl!=playerB.ball_ctrl)
errorMsg << _T("\tball_ctrl: ") << (int)playerA.ball_ctrl <<_T(" / ") << (int)playerB.ball_ctrl <<_T("\r\n");
if(playerA.ball_win!=playerB.ball_win)
errorMsg << _T("\tball_win: ") << (int)playerA.ball_win <<_T(" / ") << (int)playerB.ball_win <<_T("\r\n");
if(playerA.body_ctrl!=playerB.body_ctrl)
errorMsg << _T("\tbody_ctrl: ") << (int)playerA.body_ctrl <<_T(" / ") << (int)playerB.body_ctrl <<_T("\r\n");
if(playerA.catching!=playerB.catching)
errorMsg << _T("\tcatching: ") << (int)playerA.catching <<_T(" / ") << (int)playerB.catching <<_T("\r\n");
if(playerA.clearing!=playerB.clearing)
errorMsg << _T("\tclearing: ") << (int)playerA.clearing <<_T(" / ") << (int)playerB.clearing <<_T("\r\n");
// (playerA.copy_id!=playerB.copy_id);
if(playerA.cover!=playerB.cover)
errorMsg << _T("\tcover: ") << (int)playerA.cover <<_T(" / ") << (int)playerB.cover <<_T("\r\n");
if(playerA.def!=playerB.def)
errorMsg << _T("\tdef: ") << (int)playerA.def <<_T(" / ") << (int)playerB.def <<_T("\r\n");
if(playerA.drib!=playerB.drib)
errorMsg << _T("\tdrib: ") << (int)playerA.drib <<_T(" / ") << (int)playerB.drib <<_T("\r\n");
if(playerA.exp_pwr!=playerB.exp_pwr)
errorMsg << _T("\texp_pwr: ") << (int)playerA.exp_pwr <<_T(" / ") << (int)playerB.exp_pwr <<_T("\r\n");
if(playerA.finish!=playerB.finish)
errorMsg << _T("\tfinish: ") << (int)playerA.finish <<_T(" / ") << (int)playerB.finish <<_T("\r\n");
if(playerA.gk!=playerB.gk)
errorMsg << _T("\tgk: ") << (int)playerA.gk <<_T(" / ") << (int)playerB.gk <<_T("\r\n");
if(playerA.header!=playerB.header)
errorMsg << _T("\theader: ") << (int)playerA.header <<_T(" / ") << (int)playerB.header <<_T("\r\n");
if(playerA.jump!=playerB.jump)
errorMsg << _T("\tjump: ") << (int)playerA.jump <<_T(" / ") << (int)playerB.jump <<_T("\r\n");
if(playerA.kick_pwr!=playerB.kick_pwr)
errorMsg << _T("\tkick_pwr: ") << (int)playerA.kick_pwr <<_T(" / ") << (int)playerB.kick_pwr <<_T("\r\n");
if(playerA.loftpass!=playerB.loftpass)
errorMsg << _T("\tloftpass: ") << (int)playerA.loftpass <<_T(" / ") << (int)playerB.loftpass <<_T("\r\n");
if(playerA.lowpass!=playerB.lowpass)
errorMsg << _T("\tlowpass: ") << (int)playerA.lowpass <<_T(" / ") << (int)playerB.lowpass <<_T("\r\n");
//if(playerA.nation!=playerB.nation)
// errorMsg << _T("\tName: ") << (int)playerA.name <<_T(" / ") << (int)playerB.name <<_T("\r\n");
if(pesVersion!=16 && playerA.phys_cont!=playerB.phys_cont)
errorMsg << _T("\tphys_cont: ") << (int)playerA.phys_cont <<_T(" / ") << (int)playerB.phys_cont <<_T("\r\n");
if(playerA.place_kick!=playerB.place_kick)
errorMsg << _T("\tplace_kick: ") << (int)playerA.place_kick <<_T(" / ") << (int)playerB.place_kick <<_T("\r\n");
if(playerA.play_style!=playerB.play_style)
errorMsg << _T("\tplay_style: ") << (int)playerA.play_style <<_T(" / ") << (int)playerB.play_style <<_T("\r\n");
if(playerA.reflex!=playerB.reflex)
errorMsg << _T("\treflex: ") << (int)playerA.reflex <<_T(" / ") << (int)playerB.reflex <<_T("\r\n");
if(playerA.reg_pos!=playerB.reg_pos)
errorMsg << _T("\treg_pos: ") << (int)playerA.reg_pos <<_T(" / ") << (int)playerB.reg_pos <<_T("\r\n");
if(playerA.speed!=playerB.speed)
errorMsg << _T("\tspeed: ") << (int)playerA.speed <<_T(" / ") << (int)playerB.speed <<_T("\r\n");
if(playerA.stamina!=playerB.stamina)
errorMsg << _T("\tstamina: ") << (int)playerA.stamina <<_T(" / ") << (int)playerB.stamina <<_T("\r\n");
if(playerA.strong_foot!=playerB.strong_foot)
errorMsg << _T("\tstrong_foot: ") << (int)playerA.strong_foot <<_T(" / ") << (int)playerB.strong_foot <<_T("\r\n");
if(playerA.swerve!=playerB.swerve)
errorMsg << _T("\tswerve: ") << (int)playerA.swerve <<_T(" / ") << (int)playerB.swerve <<_T("\r\n");
if(playerA.form!=playerB.form)
errorMsg << _T("\tForm: ") << (int)playerA.form <<_T(" / ") << (int)playerB.form <<_T("\r\n");
if(playerA.injury!=playerB.injury)
errorMsg << _T("\tInjury resist: ") << (int)playerA.injury <<_T(" / ") << (int)playerB.injury <<_T("\r\n");
if(playerA.weak_acc!=playerB.weak_acc)
errorMsg << _T("\tWeak foot acc: ") << (int)playerA.weak_acc <<_T(" / ") << (int)playerB.weak_acc <<_T("\r\n");
if(playerA.weak_use!=playerB.weak_use)
errorMsg << _T("\tWeak foot use: ") << (int)playerA.weak_use <<_T(" / ") << (int)playerB.weak_use <<_T("\r\n");
for(int kk=0;kk<13;kk++)
{
if(playerA.play_pos[kk]!=playerB.play_pos[kk])
errorMsg << _T("\tPlayable position ")<<kk+1<<_T(": ") << (int)playerA.play_pos[kk] <<_T(" / ") <<
(int)playerB.play_pos[kk] <<_T("\r\n");
}
for(int kk=0;kk<7;kk++)
{
if(playerA.com_style[kk]!=playerB.com_style[kk])
errorMsg <<_T("\tCOM style ")<<kk+1<<_T(": ") << (int)playerA.com_style[kk] <<_T(" / ") <<
(int)playerB.com_style[kk] <<_T("\r\n");
}
for(int kk=0;kk<28;kk++)
{
if(playerA.play_skill[kk]!=playerB.play_skill[kk])
errorMsg <<_T("\tPlayer skill ")<<kk+1<<_T(": ")<< (int)playerA.play_skill[kk] <<_T(" / ") <<
(int)playerB.play_skill[kk] <<_T("\r\n");
}
tstring testdeb = errorMsg.str();
int kkjj=0;
}
if(errorMsg.rdbuf()->in_avail())
{
msgOut+=errorMsg.str();
msgOut+=_T("\r\n");
//errorMsg.clear();
//errorMsg.str(tstring());
}
else
msgOut = _T(<