#W# Crafting queue fix/tweak.

This commit is contained in:
WarrentyExpired 2026-07-23 13:04:19 -04:00
parent ad9521ebb9
commit abee6aa3eb

View file

@ -38,7 +38,7 @@ namespace Server.Engines.Craft
public CraftQueue() public CraftQueue()
{ {
Entries = new List<CraftQueueEntry>(); Entries = new List<CraftQueueEntry>();
IsPaused = true; // Now defaults to Paused so the first click says "START" IsPaused = true;
} }
public static CraftQueue GetQueue( Mobile m ) public static CraftQueue GetQueue( Mobile m )
@ -61,7 +61,7 @@ namespace Server.Engines.Craft
if ( !queue.IsPaused ) if ( !queue.IsPaused )
{ {
queue.IsPaused = true; queue.IsPaused = true;
m.SendMessage( 0x20, $"Crafting queue paused: {reason}" ); m.SendMessage( $"Crafting queue paused: {reason}" );
} }
} }
@ -72,7 +72,6 @@ namespace Server.Engines.Craft
if ( queue.IsPaused || queue.Entries.Count == 0 ) if ( queue.IsPaused || queue.Entries.Count == 0 )
return; return;
// Find the first item that still needs crafting
CraftQueueEntry entry = null; CraftQueueEntry entry = null;
foreach ( var e in queue.Entries ) foreach ( var e in queue.Entries )
{ {
@ -85,7 +84,6 @@ namespace Server.Engines.Craft
if ( entry == null ) return; if ( entry == null ) return;
// Tally the stats
if ( success ) if ( success )
{ {
entry.Made++; entry.Made++;
@ -97,10 +95,9 @@ namespace Server.Engines.Craft
entry.Failed++; entry.Failed++;
} }
// Decrement the remaining amount
entry.Amount--; entry.Amount--;
from.SendGump( new CraftQueueGump( from, entry.System, entry.Tool ) );
// Fire the next craft automatically!
Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ), new TimerStateCallback( ProcessQueue ), from ); Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ), new TimerStateCallback( ProcessQueue ), from );
} }
@ -112,7 +109,6 @@ namespace Server.Engines.Craft
if ( queue.IsPaused ) if ( queue.IsPaused )
return; return;
// Find the active item
CraftQueueEntry entry = null; CraftQueueEntry entry = null;
foreach ( var e in queue.Entries ) foreach ( var e in queue.Entries )
{ {
@ -125,18 +121,16 @@ namespace Server.Engines.Craft
if ( entry == null ) if ( entry == null )
{ {
from.SendMessage( 0x480, "Your crafting queue is complete!" ); from.SendMessage( "Your crafting queue is complete!" );
queue.IsPaused = true; // Auto-pause for the next time they use it queue.IsPaused = true;
return; return;
} }
// Safety Check: Did the tool break?
if ( entry.Tool == null || entry.Tool.Deleted || entry.Tool.UsesRemaining <= 0 ) if ( entry.Tool == null || entry.Tool.Deleted || entry.Tool.UsesRemaining <= 0 )
{ {
Type toolType = entry.Tool != null ? entry.Tool.GetType() : null; Type toolType = entry.Tool != null ? entry.Tool.GetType() : null;
BaseTool newTool = null; BaseTool newTool = null;
// Search the player's backpack for a valid replacement tool
if ( toolType != null && from.Backpack != null ) if ( toolType != null && from.Backpack != null )
{ {
Item[] tools = from.Backpack.FindItemsByType( toolType ); Item[] tools = from.Backpack.FindItemsByType( toolType );
@ -153,19 +147,16 @@ namespace Server.Engines.Craft
if ( newTool != null ) if ( newTool != null )
{ {
// Swap the broken tool out for the spare and keep going!
entry.Tool = newTool; entry.Tool = newTool;
from.SendMessage( 0x480, "A broken tool was replaced with a spare from your backpack." ); from.SendMessage( "A broken tool was replaced with a spare from your backpack." );
} }
else else
{ {
// No spares found. Pause so they can go get one.
Pause( from, "Tool broken. Please place a new one in your backpack and hit Start." ); Pause( from, "Tool broken. Please place a new one in your backpack and hit Start." );
return; return;
} }
} }
// Figure out what resource (wood, ingot type, etc) they had selected
CraftContext context = entry.System.GetContext( from ); CraftContext context = entry.System.GetContext( from );
Type typeRes = null; Type typeRes = null;
if ( context != null ) if ( context != null )
@ -176,12 +167,9 @@ namespace Server.Engines.Craft
typeRes = res.GetAt( resIndex ).ItemType; typeRes = res.GetAt( resIndex ).ItemType;
} }
// Close existing gumps so the screen doesn't spam
from.CloseGump( typeof( CraftGump ) ); from.CloseGump( typeof( CraftGump ) );
from.CloseGump( typeof( CraftQueueGump ) );
from.CloseGump( typeof( CraftGumpItem ) ); from.CloseGump( typeof( CraftGumpItem ) );
// Start the next craft!
entry.Item.Craft( from, entry.System, typeRes, entry.Tool ); entry.Item.Craft( from, entry.System, typeRes, entry.Tool );
} }
} }