10th Anniversary Edition (Version B)

Update: save comparator now supports 20/21 save files
Update: added error handling for save comparator
Update: added group boxes to Teams tab
master
Noteperson 2021-03-07 13:01:05 -06:00
parent 46fe2423c9
commit 156fcb472d
4 changed files with 91 additions and 14 deletions

View File

@ -13,11 +13,10 @@
typedef std::wstringstream tstringstream;
#endif
void compare_data_handler(const TCHAR*, int);
void compare_data_handler(const TCHAR*, int, void*);
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;
@ -32,7 +31,7 @@ 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)
void save_comparator(HWND hCompareBox, int nPesVersion, player_entry* gplayers, int gnum_players, team_entry* gteams, int gnum_teams, TCHAR *cs_file_name, void *hc_descriptor)
{
// //Open dialog box to get file path
// OPENFILENAME ofn;
@ -53,7 +52,7 @@ void save_comparator(HWND hCompareBox, int nPesVersion, player_entry* gplayers,
//
// if(GetOpenFileName(&ofn))
{
compare_data_handler(cs_file_name, nPesVersion);
compare_data_handler(cs_file_name, nPesVersion, hc_descriptor);
//Do comparison between players, teams
tstring result = do_comparison(nPesVersion, gplayers, gnum_players, gteams, gnum_teams);
@ -84,7 +83,7 @@ void save_comparator(HWND hCompareBox, int nPesVersion, player_entry* gplayers,
}
}
void compare_data_handler(const TCHAR *pcs_file_name, int nPesVersion)
void compare_data_handler(const TCHAR *pcs_file_name, int nPesVersion, void* hc_descriptor)
{
int ii, current_byte, appearance_byte;
const uint8_t* pMasterKey;
@ -244,7 +243,7 @@ void compare_data_handler(const TCHAR *pcs_file_name, int nPesVersion)
fill_team_tactics18(current_byte, hc_descriptor, c_teams, c_num_teams);
}
}
else // PES 19
else if(nPesVersion==19)
{
hc_descriptor = (void*)createFileDescriptorNew();
pMasterKey = (const uint8_t*)GetProcAddress(hPesDecryptDLL, "MasterKeyPes19");
@ -294,6 +293,51 @@ void compare_data_handler(const TCHAR *pcs_file_name, int nPesVersion)
fill_team_tactics19(current_byte, hc_descriptor, c_teams, c_num_teams);
}
}
else // PES 20/21
{
hc_descriptor = (void*)createFileDescriptorNew();
if(nPesVersion==20)
pMasterKey = (const uint8_t*)GetProcAddress(hPesDecryptDLL, "MasterKeyPes20");
else
pMasterKey = (const uint8_t*)GetProcAddress(hPesDecryptDLL, "MasterKeyPes21");
uint8_t *pfin = readFile(pcs_file_name, NULL);
decryptWithKeyNew((FileDescriptorNew*)hc_descriptor, pfin, reinterpret_cast<const char*>(pMasterKey));
//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(int ii=0;ii<c_num_players;ii++)
{
fill_player_entry20(c_players[ii], current_byte, hc_descriptor);
}
//place team entries into array of structs
current_byte = 0x8ED2FC;
c_teams = new team_entry[c_num_teams];
for(int ii=0;ii<c_num_teams;ii++)
{
fill_team_ids20(c_teams[ii], current_byte, hc_descriptor);
}
current_byte = 0x9D4648;
for(int ii=0;ii<c_num_teams;ii++)
{
fill_team_rosters20(current_byte, hc_descriptor, c_teams, c_num_teams);
}
current_byte = 0xA09880;
for(int ii=0;ii<c_num_teams;ii++)
{
fill_team_tactics20(current_byte, hc_descriptor, c_teams, c_num_teams);
}
}
//Find, hide loose players
int jj, kk;
@ -467,6 +511,8 @@ tstring compare_single_team(int pesVersion, int teamSel, player_entry* gplayers,
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(pesVersion>19 && playerA.aggres!=playerB.aggres)
errorMsg << _T("\taggression: ") << (int)playerA.aggres <<_T(" / ") << (int)playerB.aggres <<_T("\r\n");
if(playerA.form!=playerB.form)
errorMsg << _T("\tForm: ") << (int)playerA.form <<_T(" / ") << (int)playerB.form <<_T("\r\n");
@ -490,6 +536,7 @@ tstring compare_single_team(int pesVersion, int teamSel, player_entry* gplayers,
}
int numSkill;
if(pesVersion==19) numSkill=39;
else if(pesVersion>19) numSkill=41;
else numSkill=28;
for(int kk=0;kk<numSkill;kk++)
{

View File

@ -655,7 +655,7 @@ void extract_team_tactics20(team_entry, int &, void*);
void aatf_single(HWND, int, int, player_entry*, team_entry*, int);
void save_comparator(HWND, int, player_entry*, int, team_entry*, int, TCHAR*);
void save_comparator(HWND, int, player_entry*, int, team_entry*, int, TCHAR*, void*);
//data_util.cpp functions
int read_data(int, int, int&, FileDescriptorNew*);

View File

@ -155,7 +155,7 @@ int APIENTRY _tWinMain(HINSTANCE I, HINSTANCE PI, LPTSTR CL, int SC)
ghw_main = CreateWindowEx(
0,
wc.lpszClassName,
_T("4ccEditor 10th Anniversary Edition (Version A)"),
_T("4ccEditor 10th Anniversary Edition (Version B)"),
WS_OVERLAPPEDWINDOW,
20, 20, 1120+144, 700,
NULL, NULL, ghinst, NULL);
@ -4626,7 +4626,27 @@ BOOL CALLBACK aatf_comp_dlg_proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM
case WM_INITDIALOG:
{
TCHAR* cs_file_path = (TCHAR*)lParam;
save_comparator(hwnd, giPesVersion, gplayers, gnum_players, gteams, gnum_teams, cs_file_path);
void *hc_descriptor = NULL;
__try
{
save_comparator(hwnd, giPesVersion, gplayers, gnum_players, gteams, gnum_teams, cs_file_path, hc_descriptor);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
TCHAR errBuffer[MAX_PATH] = _T("");
_stprintf_s(errBuffer, MAX_PATH, _T("File decryption failed with code %d.\nThe EDIT file is from a different PES version and cannot be used for comparison."),
GetExceptionCode());
MessageBox(ghw_main, errBuffer, _T("Error!"), MB_ICONEXCLAMATION | MB_OK);
if(hc_descriptor)
{
if(giPesVersion>=18)
destroyFileDescriptorNew((FileDescriptorNew*)hc_descriptor);
else
destroyFileDescriptorOld((FileDescriptorOld*)hc_descriptor);
hc_descriptor = NULL;
}
EndDialog(hwnd, IDB_AATFOK);
}
}
break;
case WM_COMMAND:

View File

@ -1967,10 +1967,15 @@ void setup_tab3(HWND H)
SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE);
SetWindowSubclass(ghw_tab3, tab_three_dlg_proc, 0, (DWORD_PTR)chd_rect);
hw_new = CreateWindowEx(0, _T("Button"), _T("Team Colors"),
BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP,
10, 5, 207, 168, ghw_tab3, (HMENU)IDC_STATIC_T1, GetModuleHandle(NULL), NULL);
setup_control(hw_new, ghFont, scale_cntl_proc);
x1 = 20;
x2 = 100;
y1 = 12;
y2 = 82;
y1 = 25;
y2 = 95;
ydiff=22;
//Red 1
@ -2027,7 +2032,7 @@ void setup_tab3(HWND H)
//Color 1 button
hw_new = CreateWindowEx(0, _T("Button"), NULL,
BS_PUSHBUTTON | BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
155, 19, 50, 50, ghw_tab3, (HMENU)IDB_TCOLOR1, GetModuleHandle(NULL), NULL);
155, y1+6, 50, 50, ghw_tab3, (HMENU)IDB_TCOLOR1, GetModuleHandle(NULL), NULL);
setup_control(hw_new, ghFont, scale_cntl_proc);
//Red 2
@ -2084,12 +2089,17 @@ void setup_tab3(HWND H)
//Color 2 button
hw_new = CreateWindowEx(0, _T("Button"), NULL,
BS_PUSHBUTTON | BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
155, 19+y2-y1, 50, 50, ghw_tab3, (HMENU)IDB_TCOLOR2, GetModuleHandle(NULL), NULL);
155, y2+6, 50, 50, ghw_tab3, (HMENU)IDB_TCOLOR2, GetModuleHandle(NULL), NULL);
setup_control(hw_new, ghFont, scale_cntl_proc);
hw_new = CreateWindowEx(0, _T("Button"), _T("Team Data"),
BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP,
10, 178, 207, 70, ghw_tab3, (HMENU)IDC_STATIC_T1, GetModuleHandle(NULL), NULL);
setup_control(hw_new, ghFont, scale_cntl_proc);
x1 = 20;
x2 = 100;
y2 = 282;
y2 = 198;
//Manager ID
hw_new = CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""),