Hi all,

i'm using RBT (0.7.6) and Perforce (P4/LINUX26X86_64/2016.1/1404799) and 
while creating a review sometimes (rarely to be honest) happens that a file 
is not correctly parsed and not showing any diff (and i get the error: the 
patch to 'path/to/my/file' didn't apply cleanly). I've attached one of 
those file to this post, so maybe you can help me to understand if is a 
format error from our side or maybe a RB bug :)

Thanks,
Max

-- 
Supercharge your Review Board with Power Pack: 
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: 
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to reviewboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
using System.Collections;
using System.Collections.Generic;
using Svelto.DataStructures;
using Svelto.Factories;
using Svelto.IoC;
using Svelto.ServiceLayer;
using Svelto.Tasks;
using Svelto.Ticker;
using UnityEngine;

namespace Mothership
{
    internal class PurchaseRefresher : ITickable
    {
        [Inject] public IServiceRequestFactory      serviceFactory          { set; private get; }
        [Inject] public PremiumMembership           premiumMembership       { set; private get; }
        [Inject] public IGameObjectFactory          gameObjectFactory       { set; private get; }
        [Inject] public ICubeInventory              cubeInventory           { set; private get; }
        [Inject] public OpenSalvageCrateController  salvageCrateController  { private get; set; }
        [Inject] public IServiceRequestFactory serviceRequestFactory { set; private get; }
        [Inject] internal PromoCodeItemsAwardedController promoItemsAwardedController { set; private get; }
        [Inject] internal IGUIInputControllerMothership guiInputController { set; private get; }

        public void Tick(float deltaSec)
        {
            if (_retries > 0)
            {
                if (_untilNow <= 0)
                {
                    _untilNow = 10;
                    LoadPurchases();
                    _retries--;
                }
                else
                    _untilNow -= deltaSec;
            }
        }
        
        public void PollForPurchases(bool purchaseTriggered)
        {
            _untilNow = 0;
            if (purchaseTriggered)
            {
                if (_retries == 0)
                    _retries = 10;
                ShowLoadingScreen("strVerifyingPurchase");
            }
            else
            {
                ShowLoadingScreen("strConnectingToServer");
                _retries = 1;
            }
        }

        public AsyncTask RequestDataAsTask()
        {
            ILoadPurchasesRequest service = serviceFactory.Create<ILoadPurchasesRequest>();
            service.SetAnswer(new ServiceAnswer<FasterList<PurchaseRequestData>>(OnPurchasesLoaded, OnPurchasesLoadFail));
            return new AsyncTask(service as ITask);
        }

        void LoadPurchases()
        {
            if (_requestIsLoading == false)
            {
                Utility.Console.Log("LoadPurchases retry: " + _retries);
                _requestIsLoading = true;
                ILoadPurchasesRequest loadPurchasesRequest = serviceFactory.Create<ILoadPurchasesRequest>();
                loadPurchasesRequest.SetAnswer(new ServiceAnswer<FasterList<PurchaseRequestData>>(OnPurchasesLoaded, OnPurchasesLoadFail));
                loadPurchasesRequest.Execute();
            }
        }

        void OnPurchasesLoaded(FasterList<PurchaseRequestData> purchases)
        {
            Utility.Console.Log("LoadPurchases retry: done " + _retries);
            if (purchases.Count > 0)
            {
                _retries = 0;
                int totalCratesPurchased = 0;
                Dictionary<string, object> cubesAwarded = null;
                for (int i = 0; i < purchases.Count; i++)
                {
                    PurchaseRequestData requestData = purchases[i];
                    switch (requestData.ShopItemType)
                    {
                        case ShopItemType.Premium:
                            premiumMembership.UpdatePremiumPurchase(requestData.premiumPurchaseResponse);
                            break;

                        case ShopItemType.Crate:
                            totalCratesPurchased = requestData.totalCrates;
                            break;

                        case ShopItemType.Cube:
                            for (var enumer = requestData.newCubeTotals.GetEnumerator(); enumer.MoveNext(); )
                            {
                                var current = enumer.Current;
                                cubeInventory.SetCubeTotal(new CubeTypeID(current.Key), current.Value);
                            }
                            cubesAwarded = requestData.cubesAwarded;
                            break;
                    }                    
                }

                if (totalCratesPurchased > 0)
                {
                    HandlePurchaseCrates(totalCratesPurchased, cubesAwarded);
                }
            }

            if (_retries == 0)
                HideLoadingScreen();

            _requestIsLoading = false;
        }

        void HandlePurchaseCrates(int cratesToBuy, Dictionary<string, object> cubesAwarded)
        {
            AnalyticsEvent.LogCratePurchaseSuccess(cratesToBuy);
            TaskRunner.Instance.DeepRun(ShowPurchasedCratesSuccessDialogs(cubesAwarded));
        }

        IEnumerator ShowPurchasedCratesSuccessDialogs(Dictionary<string, object> cubesAwarded)
        {
            int totalCratesCount = 0;
            //first part
            ShowLoadingScreen("strConnectingToServer");

            yield return salvageCrateController.PrepareCratesToView((serviceBehaviour) => ErrorWindow.ShowServiceErrorWindow(serviceBehaviour, () => ShowLoadingScreen("strConnectingToServer")));

            HideLoadingScreen();

            //second part
            IServiceAnswer<List<Loot.LootCrate>> loadBatchRequestAnswerObject = new ServiceAnswer<List<Loot.LootCrate>>((result) => 
                        {
                            totalCratesCount = result.Count;
                        },  
                        (behaviour) => ErrorWindow.ShowServiceErrorWindow(behaviour, () => ShowLoadingScreen("strConnectingToServer")));

            IGetLootCrateBatchRequest loadCratesRequest = serviceRequestFactory.Create<IGetLootCrateBatchRequest, GetLootCrateBatchRequestInputDependancy>(new GetLootCrateBatchRequestInputDependancy());
            loadCratesRequest.SetAnswer(loadBatchRequestAnswerObject);
            AsyncTask newTask = new AsyncTask(loadCratesRequest as ITask);
            
            yield return newTask;
            
            salvageCrateController.ShowSalvageCrateScreen(totalCratesCount);

            while (salvageCrateController.IsActive())
            {
                yield return null;
            }
            
            if (cubesAwarded != null)
            {
                promoItemsAwardedController.SetAwardedCubeDataAndShowScreen(cubesAwarded);
            }

            while (promoItemsAwardedController.IsActive())
            {
                yield return null;
            }

            guiInputController.CloseCurrentScreen();

            yield return null;
        }

        void OnPurchasesLoadFail(ServiceBehaviour behaviour)
        {
            _requestIsLoading = false;
            HideLoadingScreen();
            ErrorWindow.ShowServiceErrorWindow(behaviour);
        }

        void ShowLoadingScreen(string loadingStrKey)
        {
            if (_loadingScreen == null)
            {
                _loadingScreen = gameObjectFactory.Build(Prefabs.ServiceLoadingIcon);
                _loadingScreen.GetComponent<GenericLoadingScreen>().text = StringTable.Instance.GetString(loadingStrKey);
            }

            _loadingScreen.gameObject.SetActive(true);
        }

        void HideLoadingScreen()
        {
            if(_loadingScreen)
                _loadingScreen.gameObject.SetActive(false);
        }
        
        bool _requestIsLoading = false;
        int _retries = 0;
        float _untilNow = 0f;
        GameObject _loadingScreen = null;
    }
}

Reply via email to