Improved ship controller boot delay
Down from 3 to 0.6 s with default startup script This is a pre-requisite for the upcoming mainframe
This commit is contained in:
parent
1a3e60b53e
commit
becfbac554
3 changed files with 27 additions and 12 deletions
|
@ -76,7 +76,9 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy {
|
|||
public int randomWarmupAddition = 0;
|
||||
|
||||
private int chestTeleportUpdateTicks = 0;
|
||||
private int registryUpdateTicks = 15;
|
||||
private final int registryUpdateInterval_ticks = 20 * WarpDriveConfig.WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS;
|
||||
private int registryUpdateTicks = 0;
|
||||
private int bootTicks = 20;
|
||||
public String coreFrequency = "default";
|
||||
|
||||
public int isolationBlocksCount = 0;
|
||||
|
@ -128,24 +130,31 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy {
|
|||
}
|
||||
|
||||
// Update warp core in cores registry
|
||||
registryUpdateTicks++;
|
||||
if (registryUpdateTicks > WarpDriveConfig.WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS * 20) {
|
||||
registryUpdateTicks = 0;
|
||||
// accelerate update ticks during boot
|
||||
if (bootTicks > 0) {
|
||||
bootTicks--;
|
||||
if (controller == null) {
|
||||
registryUpdateTicks = 1;
|
||||
}
|
||||
}
|
||||
registryUpdateTicks--;
|
||||
if (registryUpdateTicks <= 0) {
|
||||
registryUpdateTicks = registryUpdateInterval_ticks;
|
||||
WarpDrive.shipCores.updateInRegistry(this);
|
||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||
WarpDrive.shipCores.printRegistry();
|
||||
WarpDrive.logger.info(this + " controller is " + controller + ", warmupTime " + warmupTime + ", currentMode " + currentMode + ", jumpFlag "
|
||||
+ (controller == null ? "NA" : controller.isJumpFlag()) + ", cooldownTime " + cooldownTime);
|
||||
}
|
||||
|
||||
TileEntity c = findControllerBlock();
|
||||
if (c == null) {
|
||||
|
||||
TileEntity controllerFound = findControllerBlock();
|
||||
if (controllerFound == null) {
|
||||
controller = null;
|
||||
warmupTime = 0;
|
||||
soundPlayed = false;
|
||||
return;
|
||||
}
|
||||
controller = (TileEntityShipController) c;
|
||||
controller = (TileEntityShipController) controllerFound;
|
||||
}
|
||||
|
||||
isolationUpdateTicks++;
|
||||
|
|
|
@ -119,6 +119,7 @@ public class WarpDriveConfig {
|
|||
public static int WC_WARMUP_LONGJUMP_SECONDS = 30;
|
||||
public static int WC_WARMUP_RANDOM_TICKS = 60;
|
||||
public static int WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = 10;
|
||||
public static int WC_CONTROLLER_UPDATE_INTERVAL_SECONDS = 2;
|
||||
public static int WC_ISOLATION_UPDATE_INTERVAL_SECONDS = 10;
|
||||
public static String[] WC_UNLIMITED_PLAYERNAMES = { "notch", "someone" };
|
||||
public static boolean WC_WARMUP_SICKNESS = true;
|
||||
|
@ -361,6 +362,8 @@ public class WarpDriveConfig {
|
|||
|
||||
WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = config.get("WarpCore", "cores_registry_update_interval", WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS,
|
||||
"(measured in seconds)").getInt();
|
||||
WC_CONTROLLER_UPDATE_INTERVAL_SECONDS = config.get("WarpCore", "controller_update_interval", WC_CONTROLLER_UPDATE_INTERVAL_SECONDS,
|
||||
"(measured in seconds)").getInt();
|
||||
WC_ISOLATION_UPDATE_INTERVAL_SECONDS = config.get("WarpCore", "isolation_update_interval", WC_ISOLATION_UPDATE_INTERVAL_SECONDS,
|
||||
"(measured in seconds)").getInt();
|
||||
WC_UNLIMITED_PLAYERNAMES = config.get("WarpCore", "unlimited_playernames", WC_UNLIMITED_PLAYERNAMES,
|
||||
|
|
|
@ -368,8 +368,6 @@ else
|
|||
}
|
||||
end
|
||||
|
||||
SetColorDeflt()
|
||||
|
||||
Side = { "bottom", "top", "back", "left", "right" }
|
||||
for i = 1,5 do
|
||||
if peripheral.getType(Side[i]) == "warpdriveShipController" then
|
||||
|
@ -381,10 +379,13 @@ for i = 1,5 do
|
|||
end
|
||||
|
||||
if warp == nil then
|
||||
ShowWarning("No warpcore controller detected")
|
||||
ShowWarning("No ship controller detected")
|
||||
os.pullEvent("key")
|
||||
os.reboot()
|
||||
end
|
||||
print("Ship controller detected...")
|
||||
|
||||
SetColorDeflt()
|
||||
|
||||
if SData.Shipname == "" then
|
||||
SetShipName()
|
||||
|
@ -403,11 +404,13 @@ repeat
|
|||
pos = warp.pos()
|
||||
sleep(0.3)
|
||||
until pos ~= nil
|
||||
print("Ship core detected...")
|
||||
X, Y, Z = warp.pos()
|
||||
repeat
|
||||
isAttached = warp.isAttached()
|
||||
sleep(0.3)
|
||||
until isAttached ~= false
|
||||
print("Ship core linked...")
|
||||
|
||||
repeat
|
||||
Weight = warp.getShipSize()
|
||||
|
@ -427,7 +430,7 @@ while(mainloop) do
|
|||
ShowMenu("D - Dimensions, M - Toggle summon, N - Ship name")
|
||||
ShowMenu("S - Set Warp Data, J - Jump, G - Jump to JumpGate")
|
||||
ShowMenu("B - Jump to Beacon, H - Jump to Hyperspace")
|
||||
ShowMenu("C - Summon crew, X - Shutdown WarpCore and Exit")
|
||||
ShowMenu("C - Summon crew, X - Shutdown Controller and Exit")
|
||||
SetColorDeflt()
|
||||
local event, keycode = os.pullEvent("key")
|
||||
if keycode == 31 then
|
||||
|
|
Loading…
Add table
Reference in a new issue