From 6618d466577352e877e2e2c3e610a6d437b9a7e0 Mon Sep 17 00:00:00 2001 From: Aingar <47479741+Aingar@users.noreply.github.com> Date: Sat, 25 Nov 2023 15:00:48 +0100 Subject: [PATCH] Conn update, conn-POB removal, fixes. -Revert to updating the player file upon inputting /conn, as doing so after they launch can randomly fail. -Can no longer /conn from POBs to prevent ammo-related abuse -Also minor code cleanup. --- Plugins/Public/conn_plugin/Main.cpp | 58 +++++++++-------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/Plugins/Public/conn_plugin/Main.cpp b/Plugins/Public/conn_plugin/Main.cpp index f676922a7..04c54bb70 100644 --- a/Plugins/Public/conn_plugin/Main.cpp +++ b/Plugins/Public/conn_plugin/Main.cpp @@ -174,23 +174,12 @@ bool ValidateCargo(unsigned int client) void StoreCurrentBase(uint client) { - CUSTOM_BASE_IS_DOCKED_STRUCT info; - info.iClientID = client; - info.iDockedBaseID = 0; - Plugin_Communication(CUSTOM_BASE_IS_DOCKED, &info); - // It's not docked at a custom base, check for a regular base - if (info.iDockedBaseID) - { - connInfo[client].retBase = info.iDockedBaseID; - connInfo[client].retSystemBackup = Players[client].iSystemID; - } - else - { - uint currBase; - pub::Player::GetBase(client, currBase); - connInfo[client].retBase = currBase; - connInfo[client].retSystemBackup = 0; - } + + uint currBase; + pub::Player::GetBase(client, currBase); + connInfo[client].retBase = currBase; + connInfo[client].retSystemBackup = 0; + } void StoreReturnPointForClient(unsigned int client) @@ -205,18 +194,6 @@ void StoreReturnPointForClient(unsigned int client) } } -void SimulateF1(uint client, uint baseId) -{ - Server.BaseEnter(baseId, client); - Server.BaseExit(baseId, client); - wstring wscCharFileName; - HkGetCharFileName(ARG_CLIENTID(client), wscCharFileName); - wscCharFileName += L".fl"; - CHARACTER_ID cID; - strcpy(cID.szCharFilename, wstos(wscCharFileName.substr(0, 14)).c_str()); - Server.CharacterSelect(cID, client); -} - void MoveClient(unsigned int client, unsigned int targetBase) { // Ask that another plugin handle the beam. @@ -235,11 +212,7 @@ void MoveClient(unsigned int client, unsigned int targetBase) Universe::IBase* base = Universe::get_base(targetBase); if (base) { - pub::Player::ForceLand(client, targetBase); // beam // if not in the same system, emulate F1 charload - if (base->iSystemID != system) - { - SimulateF1(client, targetBase); - } + HkBeamById(client, targetBase); } else { @@ -254,11 +227,7 @@ void MoveClient(unsigned int client, unsigned int targetBase) return; } PrintUserCmdText(client, L"Player base renamed/destroyed, ship redirected to a proxy base"); - pub::Player::ForceLand(client, proxyBaseID); // beam - if (returnSys != system) - { - SimulateF1(client, proxyBaseID); - } + HkBeamById(client, targetBase); } } @@ -312,11 +281,21 @@ bool UserCmd_Process(uint client, const wstring &cmd) return true; } + CUSTOM_BASE_IS_DOCKED_STRUCT info2; + info2.iClientID = client; + Plugin_Communication(CUSTOM_BASE_IS_DOCKED, &info2); + if (info2.iDockedBaseID) + { + PrintUserCmdText(client, L"ERR Cannot go to connecticut from a Player Base"); + return true; + } + if (!ValidateCargo(client)) { return true; } StoreCurrentBase(client); + StoreReturnPointForClient(client); PrintUserCmdText(client, L"Redirecting undock to Connecticut."); connInfo[client].clientState = TRANSFER; @@ -379,7 +358,6 @@ void __stdcall PlayerLaunch_AFTER(unsigned int ship, unsigned int client) connInfo[client].clientState = NONE; MoveClient(client, set_iTargetBaseID); - StoreReturnPointForClient(client); return; }