dgatsoulis
ele2png user
Hey everyone, I am having some difficulty figuring out the syntax for the following task.
I have an eva vessel, which I am deleting when it's close to a docking port and a key is pressed. Then I shift the focus to the vessel.
The code is this and it works ok so far.
Before the eva gets deleted, I want to do the following:
Get the dock's vessel name (let's call it shipname) and open a file in Config\(mydirectory)\shipname.cfg
If the file exists, look for the first line that is empty and write there the name of the eva.
If the file doesn't exist, create it and write the name of the eva on the first line.
if the file exists but there is no empty line, write the name at the end.
Example of contents of existing file in Config\(mydirectory)\XR2-01.cfg
In the example above, the name of the eva, should be placed on line 3, because it's the first empty line.
I don't know my way around c++ , so the syntax to achieve this eludes me. Any help is much appreciated.
I have an eva vessel, which I am deleting when it's close to a docking port and a key is pressed. Then I shift the focus to the vessel.
The code is this and it works ok so far.
C++:
void GVmmu::EndEVA()
{
VECTOR3 gpos, mepos, pos, dir, rot;
GetGlobalPos(mepos);
OBJHANDLE eva;
for (DWORD i = 0; i < oapiGetVesselCount(); i++)
{
OBJHANDLE hV = oapiGetVesselByIndex(i);
if (hV == GetHandle()) continue; // we don't want to grapple ourselves ...
oapiGetGlobalPos(hV, &gpos);
if (dist(gpos, mepos) < oapiGetSize(hV))
{
VESSEL *v = oapiGetVesselInterface(hV);
DWORD nDock = v->DockCount();
if (nDock == 0) continue;
for (DWORD j = 0; j < nDock; j++)
{
DOCKHANDLE hDock = v->GetDockHandle(j);
v->GetDockParams(hDock, pos, dir, rot);
v->Local2Global(pos, gpos);
if (abs(dist(gpos, mepos)) < 3) {
eva = GetHandle();
oapiDeleteVessel(eva);
oapiSetFocusObject(hV);
}
}
}
}
}
Before the eva gets deleted, I want to do the following:
Get the dock's vessel name (let's call it shipname) and open a file in Config\(mydirectory)\shipname.cfg
If the file exists, look for the first line that is empty and write there the name of the eva.
If the file doesn't exist, create it and write the name of the eva on the first line.
if the file exists but there is no empty line, write the name at the end.
Example of contents of existing file in Config\(mydirectory)\XR2-01.cfg
Code:
Lee_Nash
Kara_Miller
In the example above, the name of the eva, should be placed on line 3, because it's the first empty line.
I don't know my way around c++ , so the syntax to achieve this eludes me. Any help is much appreciated.