コード例 #1
0
        /// <summary>
        /// Notes a problem.
        /// </summary>
        /// <param name="problem">The problem.</param>
        /// <param name="serviceBuildingId">The service building identifier.</param>
        /// <param name="targetBuildingId">The target building identifier.</param>
        public void Add(ServiceProblem problem, ushort serviceBuildingId, ushort targetBuildingId)
        {
            if (this.broken)
            {
                return;
            }

            try
            {
                if (Log.LogALot)
                {
                    Log.Debug(
                        this, "Add", problem, serviceBuildingId, targetBuildingId,
                        BuildingHelper.GetBuildingName(serviceBuildingId),
                        BuildingHelper.GetDistrictName(serviceBuildingId),
                        BuildingHelper.GetBuildingName(targetBuildingId),
                        BuildingHelper.GetDistrictName(targetBuildingId));
                }

                uint key    = MakeBuildingKey(serviceBuildingId, targetBuildingId);
                byte weight = this.GetServiceProblemWeight(problem);

                uint            newValue;
                uint            oldValue;
                BuildingProblem newProblem;
                BuildingProblem oldProblem;

                bool gotSize    = this.ProblemSizes.TryGetValue(key, out oldValue);
                bool gotProblem = this.TargetBuildingProblems.TryGetValue(targetBuildingId, out oldProblem);

                if (gotSize)
                {
                    newValue = oldValue + weight;
                }
                else
                {
                    oldValue = 0;
                    newValue = weight;
                }

                if (gotProblem)
                {
                    newProblem = new BuildingProblem(oldProblem, weight, !gotSize);
                }
                else
                {
                    newProblem = new BuildingProblem(weight);
                }

                this.ProblemSizes[key] = newValue;
                this.TargetBuildingProblems[targetBuildingId] = newProblem;

                //if (Log.LogALot)
                //{
                //    DevLog("Add",
                //        Log.Data("ServiceBuilding", serviceBuildingId, BuildingHelper.GetBuildingName(serviceBuildingId)),
                //        Log.Data("TargetBuilding", targetBuildingId, BuildingHelper.GetBuildingName(targetBuildingId)),
                //        Log.Data("Actions", (gotSize ? "Set" : "Add"), (gotProblem ? "Set" : "Add"), weight),
                //        "Problem", problem,
                //        "Key", key,
                //        "OldValue", oldValue,
                //        "OldCount", oldProblem.Count,
                //        "OldSize", oldProblem.Size,
                //        "NewValue", newValue,
                //        "NewCount", newProblem.Count,
                //        "NewSize", newProblem.Size);
                //}
            }
            catch (Exception ex)
            {
                this.broken = true;
                Log.Error(this, "Add", ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Logs the transfer offers.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="offers">The offers.</param>
        /// <param name="count">The count.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="buildings">The buildings.</param>
        /// <param name="material">The material.</param>
        private static void DebugListLog(
            string direction,
            TransferManager.TransferOffer[] offers,
            ushort[] count,
            int[] amount,
            Building[] buildings,
            TransferManager.TransferReason material)
        {
            for (int priority = 0; priority < 8; priority++)
            {
                int index = ((int)material * 8) + priority;
                for (int i = 0; i < count[index]; i++)
                {
                    Log.InfoList info = new Log.InfoList();
                    TransferManager.TransferOffer offer = offers[(index * 256) + i];

                    info.Add("Active", offer.Active);
                    info.Add("Amount", offer.Amount);
                    info.Add("Priority", offer.Priority);
                    info.Add("Vehicle", offer.Vehicle, VehicleHelper.GetVehicleName(offer.Vehicle));
                    info.Add("Citizen", offer.Citizen, CitizenHelper.GetCitizenName(offer.Citizen));
                    info.Add("TransportLine", offer.TransportLine, TransportLineHelper.GetLineName(offer.TransportLine));
                    info.Add("Building", offer.Building, BuildingHelper.GetBuildingName(offer.Building), BuildingHelper.GetDistrictName(offer.Building));

                    if (buildings != null && offer.Building > 0 && buildings[offer.Building].Info != null && (buildings[offer.Building].m_flags & Building.Flags.Created) == Building.Flags.Created)
                    {
                        info.Add("Garbage", buildings[offer.Building].m_garbageBuffer);
                        info.Add("Dead", buildings[offer.Building].m_deathProblemTimer);
                    }

                    Log.DevDebug(typeof(TransferManagerHelper), "DebugListLog", direction, material, info);
                }
            }
        }