Exemplo n.º 1
0
        // generate a WorldDef-object from the retrieved sql-results
        protected void WorldDefFromSQLResults(GUC.Utilities.Threading.AbstractRunnable sender,
                                              DBAgent.FinishedQueueEventHandlerArgs e)
        {
            // convert the sql-query-results from string to their respective datatypes
            sqlResultInUse = true;
            sqlResults     = e.GetSQLResults();
            DBTables.ConvertSQLResults(sqlResults, colGetTypeInfo, false);

            // construct the WorldDef-object according to the converted sql-data
            worldDef = new WorldDef(this);
            ApplyWorldEffects(ref worldDef, ref sqlResults, ref colGetTypeInfo);

            // initalize VobInst-objects from database via loaders of the VobSystem
            //VobSystem.VobInstLoader vobInstLoader = new VobSystem.VobInstLoader(ref worldDef);
            //vobInstLoader.Start();
            //vobInstLoader.FinishedLoading += delegate (object sender, FinishedLoadingArgs e)
            //{
            //    // release control over sqlResults on finishing line
            //    sqlResultInUse = false;
            //};
        }
Exemplo n.º 2
0
        protected void VobDefFromSQLResults(AbstractRunnable s, DBAgent.FinishedQueueEventHandlerArgs e)
        {
            try
            {
                var cgi = GetColGetTypeInfo();
                // convert the received database-results
                List <List <List <object> > > sqlResults = e.GetSQLResults();
                DBTables.ConvertSQLResults(sqlResults, cgi);

                int i_VobDef = DBTableLoadOrder.IndexOf("VobDef");
                List <DBTables.ColumnGetTypeInfo> cgt_VobDef  = cgi[i_VobDef];
                List <List <object> >             tableVobDef = sqlResults[DBTableLoadOrder.IndexOf("VobDef")];

                int i_VobDefEffect = DBTableLoadOrder.IndexOf("VobDefEffect");
                List <DBTables.ColumnGetTypeInfo> cgt_VobDefEffect  = cgi[i_VobDefEffect];
                List <List <object> >             tableVobDefEffect = sqlResults[DBTableLoadOrder.IndexOf("VobDefEffect")];

                Dictionary <int, Effect> effectByID = null;
                //EffectLoader effectLoader = new EffectLoader(dbFilePath, "Vob");
                EffectLoader effectLoader = new EffectLoader(GetDBFilePath(), "DefEffect", "DefChange");
                effectLoader.Load(true, (object sender, EffectLoader.FinishedLoadingEffectsArgs eff) =>
                {
                    effectByID = eff.EffectsByID;
                });

                if ((effectByID == null) || (effectByID.Count < 1))
                {
                    MakeLogError("Aborting generation of VobDef because no Effects were loaded!");
                    return;
                }

                List <IDAndEffectIDs> idAndEffectIDList = null;
                if (!TryGenerateIDAndEffectIDList(tableVobDefEffect, out idAndEffectIDList))
                {
                    MakeLogWarning("The provided parameter tableVobDefEffect was either null "
                                   + "or didn't contain any elements!");
                }

                List <int> failedIndices;
                if (!TryGenerateVobDefs(idAndEffectIDList, effectByID, out vobDefByID, out failedIndices))
                {
                    MakeLogError("Generation of VobDef failed!");

                    StringBuilder sb = new StringBuilder();
                    sb.Append("Failed to generate VobDef with [temporary index | VobDefID]: ");
                    for (int i = 0; i < failedIndices.Count; i++)
                    {
                        sb.Append("[");
                        sb.Append(i);
                        sb.Append("|");
                        if ((failedIndices[i] < 0) || (failedIndices[i] > (idAndEffectIDList.Count - 1)))
                        {
                            sb.Append("?");
                        }
                        else
                        {
                            sb.Append(failedIndices[i]);
                        }
                        sb.Append("],");
                    }
                    MakeLogError(sb.ToString());

                    return;
                }
            }
            catch (Exception ex)
            {
                MakeLogError("Failed to finish generating VodDef-objects from sqlResults: " + ex);
            }
        }