fix (core/pdump): Fix Pdump write and load thru TC Cherry picks (#10349)

* fix (core/pdump): Fix Pdump write and load thru TC Cherry picks

TC Cherry picks were over 30. I am not listing it all but i am listing authors of said relations that this pr is based on.

Co-Authored-By: Brian <runningnak3d@gmail.com>
Co-Authored-By: joschiwald <736792+joschiwald@users.noreply.github.com>
Co-Authored-By: Shauren <shauren.trinity@gmail.com>
Co-Authored-By: SnapperRy <19622383+SnapperRy@users.noreply.github.com>
Co-Authored-By: Ariel Silva <ariel-@users.noreply.github.com>
Co-Authored-By: Nick <31777+paradox@users.noreply.github.com>
Co-Authored-By: r00ty-tc <r00ty-tc@users.noreply.github.com>
Co-Authored-By: Jorge García <259712+xurxogr@users.noreply.github.com>
Co-Authored-By: Kaelima <kaelima@live.se>
Co-Authored-By: Shocker <43253032+shockerqt@users.noreply.github.com>
Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>

* fix whitespace

formatting look like it had a stroke.

* Updated in script notes

Updated in script notes to reflect it was a note from tc that was refactored in

* Acore::StringTo

* acore::stringto

Co-authored-by: Brian <runningnak3d@gmail.com>
Co-authored-by: joschiwald <736792+joschiwald@users.noreply.github.com>
Co-authored-by: Shauren <shauren.trinity@gmail.com>
Co-authored-by: SnapperRy <19622383+SnapperRy@users.noreply.github.com>
Co-authored-by: Ariel Silva <ariel-@users.noreply.github.com>
Co-authored-by: Nick <31777+paradox@users.noreply.github.com>
Co-authored-by: r00ty-tc <r00ty-tc@users.noreply.github.com>
Co-authored-by: Jorge García <259712+xurxogr@users.noreply.github.com>
Co-authored-by: Kaelima <kaelima@live.se>
Co-authored-by: Shocker <43253032+shockerqt@users.noreply.github.com>
Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
acidmanifesto
2022-01-24 19:47:16 -05:00
committed by GitHub
parent 9e6ec128ac
commit b4b7a00b94
4 changed files with 879 additions and 550 deletions

View File

@@ -816,51 +816,96 @@ public:
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
return false;
switch (PlayerDumpReader().LoadDump(fileName, account, name, characterGUID.value_or(0)))
switch (PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
{
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_BROKEN:
handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_TOO_MANY_CHARS:
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_BROKEN:
handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_TOO_MANY_CHARS:
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
static bool HandlePDumpCopyCommand(ChatHandler* handler, PlayerIdentifier player, AccountIdentifier account, Optional<std::string_view> characterName, Optional<ObjectGuid::LowType> characterGUID)
{
std::string name;
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
return false;
std::string dump;
switch (PlayerDumpWriter().WriteDumpToString(dump, player.GetGUID().GetCounter()))
{
case DUMP_SUCCESS:
break;
case DUMP_CHARACTER_DELETED:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_OPEN_ERROR: // this error code should not happen
default:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
switch (PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
{
case DUMP_SUCCESS:
break;
case DUMP_TOO_MANY_CHARS:
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_OPEN_ERROR: // this error code should not happen
case DUMP_FILE_BROKEN: // this error code should not happen
default:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
// Original TC Notes from Refactor vvv
//ToDo: use a new trinity_string for this commands
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
return true;
}
static bool HandlePDumpWriteCommand(ChatHandler* handler, std::string fileName, PlayerIdentifier player)
{
switch (PlayerDumpWriter().WriteDump(fileName, player.GetGUID().GetCounter()))
switch (PlayerDumpWriter().WriteDumpToFile(fileName, player.GetGUID().GetCounter()))
{
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_CHARACTER_DELETED:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_CHARACTER_DELETED:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
return true;