Ticket #1210: input.js.patch

File input.js.patch, 3.3 KB (added by O.Davoodi, 12 years ago)
  • input.js

     
    269269            break;
    270270        case "setup-trade-route":
    271271            // If ground or sea trade possible
    272             if ((entState.trader && hasClass(entState, "Organic") && (playerOwned || allyOwned) && hasClass(targetState, "Market")) ||
    273                 (entState.trader && hasClass(entState, "Ship") && (playerOwned || allyOwned) && hasClass(targetState, "NavalMarket")))
     272            if ((!targetState.foundation) && ((entState.trader && hasClass(entState, "Organic") && (playerOwned || allyOwned) && hasClass(targetState, "Market")) ||
     273                (entState.trader && hasClass(entState, "Ship") && (playerOwned || allyOwned) && hasClass(targetState, "NavalMarket"))))
    274274            {
    275275                var tradingData = {"trader": entState.id, "target": target};
    276276                var tradingDetails = Engine.GuiInterfaceCall("GetTradingDetails", tradingData);
    277277                var tooltip;
     278                if (tradingDetails === null)
     279                    return {"possible": false};
    278280                switch (tradingDetails.type)
    279281                {
    280282                case "is first":
     
    376378    {
    377379        target = targets[0];
    378380    }
    379 
     381    //targetState = target;
    380382    if (preSelectedAction != ACTION_NONE)
    381383    {
    382384        switch (preSelectedAction)
     
    11521154// Called by GUI when user changes preferred trading goods
    11531155function selectTradingPreferredGoods(data)
    11541156{
    1155     Engine.PostNetworkCommand({"type": "select-trading-goods", "trader": data.trader, "preferredGoods": data.preferredGoods});
     1157    Engine.PostNetworkCommand({"type": "select-trading-goods", "entities": data.entities, "preferredGoods": data.preferredGoods});
    11561158}
    11571159
    11581160// Called by GUI when user clicks exchange resources button
     
    11751177}
    11761178
    11771179// Called by GUI when user clicks training button
    1178 function addToTrainingQueue(entity, trainEntType)
     1180function addToTrainingQueue(entity, trainEntType, selection)
    11791181{
    11801182    if (Engine.HotkeyIsPressed("session.batchtrain"))
    11811183    {
    1182         if (inputState == INPUT_BATCHTRAINING)
     1184        if (selection.length == 1)
    11831185        {
    1184             // If we're already creating a batch of this unit, then just extend it
    1185             if (batchTrainingEntity == entity && batchTrainingType == trainEntType)
     1186            if (inputState == INPUT_BATCHTRAINING)
    11861187            {
    1187                 batchTrainingCount += batchIncrementSize;
    1188                 return;
     1188                // If we're already creating a batch of this unit, then just extend it
     1189                if (batchTrainingEntity == entity && batchTrainingType == trainEntType)
     1190                {
     1191                    batchTrainingCount += batchIncrementSize;
     1192                    return;
     1193                }
     1194                // Otherwise start a new one
     1195                else
     1196                {
     1197                    flushTrainingQueueBatch();
     1198                    // fall through to create the new batch
     1199                }
    11891200            }
    1190             // Otherwise start a new one
    1191             else
    1192             {
    1193                 flushTrainingQueueBatch();
    1194                 // fall through to create the new batch
    1195             }
    11961201        }
     1202        else
     1203        {
     1204            //create a new batch
     1205            Engine.PostNetworkCommand({"type": "train", "entity": entity, "template": trainEntType, "count": batchIncrementSize, "entities": selection});
     1206        }
    11971207        inputState = INPUT_BATCHTRAINING;
    11981208        batchTrainingEntity = entity;
    11991209        batchTrainingType = trainEntType;
     
    12021212    else
    12031213    {
    12041214        // Non-batched - just create a single entity
    1205         Engine.PostNetworkCommand({"type": "train", "entity": entity, "template": trainEntType, "count": 1});
     1215        Engine.PostNetworkCommand({"type": "train", "entity": entity, "template": trainEntType, "count": 1, "entities": selection});
    12061216    }
    12071217}
    12081218