Okay a bit of thread necromancing here (but its my thread so
), but after a small amount of tweaking I've figured out how to create a reversible Galactic Hyperdrive...well a piece of equipment that is single use like the Galactic Hyperdrive itself. Two source files need to be edited to achieve this, and a new entry needs to be added to the equipment.plist file. I used the source code from version 1.76.1.
First, open the legacy_random.h file in the 'src\Core' directory and go to line 108. It should look like this:
Code: Select all
OOINLINE int rotate_byte_left (int x) INLINE_CONST_FUNC;
Add below this line the following code:
Code: Select all
OOINLINE int rotate_byte_right (int x) INLINE_CONST_FUNC;
Now go down to about line129 to the following code, which should look like this:
Code: Select all
OOINLINE int rotate_byte_left(int x)
{
return ((x << 1) | (x >> 7)) & 255;
}
Now add below this code the following code:
Code: Select all
OOINLINE int rotate_byte_right(int x)
{
return ((x >> 1) | (x << 7)) & 255;
}
This has now created a new command in the source code, which will allow the program to rotate the galaxy seed right instead of left (how it normally does).
Now, open up the PlayerEntity.m file in the 'src\Core\Entities' directory and go to line 5044, which should look like this:
Code: Select all
galaxy_number++;
galaxy_number &= 7;
galaxy_seed.a = rotate_byte_left(galaxy_seed.a);
galaxy_seed.b = rotate_byte_left(galaxy_seed.b);
galaxy_seed.c = rotate_byte_left(galaxy_seed.c);
galaxy_seed.d = rotate_byte_left(galaxy_seed.d);
galaxy_seed.e = rotate_byte_left(galaxy_seed.e);
galaxy_seed.f = rotate_byte_left(galaxy_seed.f);
Now replace the entire code shown above with the following code:
Code: Select all
// Check if the GH Reverse Unit equipment is present:
if ([self hasEquipmentItem:@"EQ_GAL_DRIVE_REVERSE_UNIT"])
{
// Decrease galaxy number and do it in a safe way:
if (galaxy_number > 0)
{
galaxy_number--;
}
else // we are at galaxy 0, now we need to cycle to 7
{
galaxy_number = 7;
}
// Rotate Galaxy Seed right instead of left to change to previous Galaxy Seed:
galaxy_seed.a = rotate_byte_right(galaxy_seed.a);
galaxy_seed.b = rotate_byte_right(galaxy_seed.b);
galaxy_seed.c = rotate_byte_right(galaxy_seed.c);
galaxy_seed.d = rotate_byte_right(galaxy_seed.d);
galaxy_seed.e = rotate_byte_right(galaxy_seed.e);
galaxy_seed.f = rotate_byte_right(galaxy_seed.f);
// Remove the GH Reverse Unit equipment:
[self removeEquipmentItem:@"EQ_GAL_DRIVE_REVERSE_UNIT"];
}
else
{
galaxy_number++;
galaxy_number &= 7;
galaxy_seed.a = rotate_byte_left(galaxy_seed.a);
galaxy_seed.b = rotate_byte_left(galaxy_seed.b);
galaxy_seed.c = rotate_byte_left(galaxy_seed.c);
galaxy_seed.d = rotate_byte_left(galaxy_seed.d);
galaxy_seed.e = rotate_byte_left(galaxy_seed.e);
galaxy_seed.f = rotate_byte_left(galaxy_seed.f);
}
Now this will make the program check if the player has a piece of equipment, in this case the 'GH Reverse Unit' and if this equipment is present will allow travel to the previous galaxy and will remove the equipment after use.
Finally open up the equipment.plist file in the 'oolite.app\Resources\Config' directory and add the following code:
Code: Select all
(
10, 50000, "GH Reverse Unit",
"EQ_GAL_DRIVE_REVERSE_UNIT",
"A single use device that forces the Galactic Hyperdrive to enable travel to a previous galaxy.",
{
available_to_all = true;
}
),
This will create a new piece of equipment, the 'GH Reverse Unit', which will be available in the same systems/stations that the Galactic Hyperdrive is, and will cost the same amount of money.
So now you have the ability to travel from Galaxy 2 back to Galaxy 1, and even travel from Galaxy 1 to Galaxy 8 without having to go all the way round. This will work with the standard source code for version 1.76.1 and in the trunk. But if you are using the
modified source code for extra galaxies that I wrote then this will need to be modified to incorporate that...