Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conn update, conn-POB removal, fixes. #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 18 additions & 40 deletions Plugins/Public/conn_plugin/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -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
{
Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know this can't work because in this case Universe::get_base(targetBase) failed

Suggested change
HkBeamById(client, targetBase);
HkBeamById(client, proxyBaseID);

}

}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down