Example #1
0
 // Öffnet die ChatLog-Datei für Lesezugriff
 public bool OpenChatLog(string Filename)
 {
     if (fChatLog != null)
     {
         fChatLog.Dispose(); fChatLog = null;
     }
     // Seek funktioniert nur richtig im binary-mode. Nur ist jetzt immer /r hinter einem String
     iLineNo = 0;
     try
     {
         fChatLog = new IFStreamWrapper(Filename, FileMode.Open, FileAccess.Read);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #2
0
        //---------------------------------------------------------------------------
        // Baue einen Report zusammen
        private void DoReport(string ReportFile)
        {//TODO: fix indices from delphi port
            string      strLine = "", strTag = null, strName = null, strInsert;
            TStringList strText = new TStringList();
            int         i;
            char        cCur;

            bool[] bVisible = new bool[10]; // Ist Output sichtbar
            bVisible[0] = true;
            int  ifLevel      = 0;          // If-Ebenen-Verschachtelung
            bool bTag         = false;
            bool bConditional = false;      // Ist wahr, wenn in der Zeile ein conditional steht
            bool bName        = false;

            tbReport.Clear();
            try
            {
                IFStreamWrapper _in = new IFStreamWrapper(ReportFile);
                while (!_in.EndOfStream)
                {       // Lese alles bis zum Dateiende
                    _in.get(out cCur);
                    if (bTag)
                    {
                        if (cCur == '>')
                        {                                  // Tag ist wieder zu Ende
                            int iPos = strName.Length + 1; // Erstes Zeichen nach dem Tagnamen
                            strName   = strName.ToLower();
                            strInsert = "";
                            int aid = -1;
                            if (strName == "name")
                            {
                                strInsert = Unit.player.Name;
                            }
                            else if (strName == "if")
                            {
                                ifLevel++;
                                Debug.Assert(ifLevel < 10);
                                if (bVisible[ifLevel - 1])
                                {
                                    string strTemp = strTag.Substring(iPos, Math.Min(99, strTag.Length - iPos));
                                    iPos = strTemp.IndexOf(' ') + 1;
                                    if (PieceStat(strTemp, out strInsert, ref iPos) == 0)
                                    {
                                        bVisible[ifLevel] = false;
                                    }
                                    else
                                    {
                                        bVisible[ifLevel] = true;
                                    }
                                }
                                else
                                {
                                    bVisible[ifLevel] = false;
                                }
                                bConditional = true;
                                //						strInsert = "";
                            }
                            else if (strName == "endif")
                            {
                                ifLevel--;
                                bConditional = true;
                            }
                            else if (strName == "else")
                            {
                                if (bVisible[ifLevel - 1])
                                {
                                    bVisible[ifLevel] = !bVisible[ifLevel];
                                }
                                bConditional = true;
                            }
                            else if (strName == "level")
                            {
                                strInsert = (Unit.player.Level).ToString();
                            }
                            else if (strName == "totalcost")
                            {
                                strInsert = Unit.frmMain.lbSCCost.Text;
                            }
                            else if (strName == "str")
                            {
                                aid = Unit.xml_config.GetAttributeId("STRENGTH");
                            }
                            else if (strName == "con")
                            {
                                aid = Unit.xml_config.GetAttributeId("CONSTITUTION");
                            }
                            else if (strName == "dex")
                            {
                                aid = Unit.xml_config.GetAttributeId("DEXTERITY");
                            }
                            else if (strName == "qui")
                            {
                                aid = Unit.xml_config.GetAttributeId("QUICKNESS");
                            }
                            else if (strName == "int")
                            {
                                aid = Unit.xml_config.GetAttributeId("INTELLIGENCE");
                            }
                            else if (strName == "pie")
                            {
                                aid = Unit.xml_config.GetAttributeId("PIETY");
                            }
                            else if (strName == "cha")
                            {
                                aid = Unit.xml_config.GetAttributeId("CHARISMA");
                            }
                            else if (strName == "emp")
                            {
                                aid = Unit.xml_config.GetAttributeId("EMPATHY");
                            }
                            else if (strName == "hits")
                            {
                                aid = Unit.xml_config.GetAttributeId("HITPOINTS");
                            }
                            else if (strName == "power")
                            {
                                aid = Unit.xml_config.GetAttributeId("POWER");
                            }
                            else if (strName == "crush")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_CRUSH");
                            }
                            else if (strName == "slash")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_SLASH");
                            }
                            else if (strName == "thrust")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_THRUST");
                            }
                            else if (strName == "heat")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_HEAT");
                            }
                            else if (strName == "cold")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_COLD");
                            }
                            else if (strName == "matter")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_MATTER");
                            }
                            else if (strName == "body")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_BODY");
                            }
                            else if (strName == "spirit")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_SPIRIT");
                            }
                            else if (strName == "energy")
                            {
                                aid = Unit.xml_config.GetAttributeId("RES_ENERGY");
                            }
                            else if (strName == "skills")
                            {   // Alles Skills listen
                                for (int skill = 0; skill < Unit.xml_config.arClasses[Unit.player.Class].nSkills; skill++)
                                {
                                    int a = Unit.xml_config.arClasses[Unit.player.Class].arSkills[skill];
                                    // Allerdings nur, wenn höher als 0
                                    if (bVisible[ifLevel] && (Unit.player.Attributes.Value[a] > 0))
                                    {
                                        strText.Add((Unit.player.Attributes.Value[a]).ToString() + " " + Unit.xml_config.arAttributes[a].Name);
                                    }
                                }
                            }
                            else if (strName == "skill")
                            {
                                int skill = strTag.Substring(iPos, Math.Min(2, strTag.Length - iPos)).ToIntDef(0);
                                iPos += 3;
                                if ((skill > 0) && (skill <= Unit.xml_config.arClasses[Unit.player.Class].nSkills))
                                {
                                    int a = Unit.xml_config.arClasses[Unit.player.Class].arSkills[skill - 1];
                                    strInsert = (Unit.player.Attributes.Value[a]).ToString() + " " + Unit.xml_config.arAttributes[a].Name;
                                }
                            }
                            else if (strName.Length > 5 && strName.Substring(0, 5) == "focus")
                            {
                                int focus = strTag.Substring(5, 1).ToIntDef(0);
                                int fg    = Unit.xml_config.GetGroupId("FOCUS");
                                if ((focus > 0) && (fg >= 0))
                                {
                                    int c = 0;
                                    for (i = 0; i < Unit.xml_config.nBonuses; i++)
                                    {
                                        if ((Unit.xml_config.arBonuses[i].idGroup == fg) && (Unit.xml_config.arBonuses[i].arAttributes.Length == 1))
                                        {
                                            int fid = Unit.xml_config.arBonuses[i].arAttributes[0];
                                            if ((Unit.player.Attributes.Value[fid] > 0) &&
                                                (Unit.xml_config.arAttributes[fid].SkillId >= 0) &&
                                                Unit.player.AttributeUseable(Unit.xml_config.arAttributes[fid].SkillId))
                                            {
                                                c++;
                                                if (c == focus)
                                                {
                                                    strInsert = (Unit.player.Attributes.Value[fid]).ToString() + " " + Unit.xml_config.arAttributes[fid].Name;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else if (strName == "capbonuses")
                            {   // Liste die Cap-Boni
                                for (i = 0; i < Unit.xml_config.nAttributes; i++)
                                {
                                    if (Unit.xml_config.arAttributes[i].CapId >= 0 && !Unit.xml_config.arAttributes[i].bCapAttr)
                                    {
                                        int cid = Unit.xml_config.arAttributes[i].CapId;
                                        if ((Unit.player.Attributes.Cap[cid] > 0) && bVisible[ifLevel])
                                        {
                                            strText.Add((Unit.player.Attributes.Cap[cid]).ToString() + " " + Unit.xml_config.arAttributes[cid].Name);
                                        }
                                    }
                                }
                            }
                            else if (strName == "otherbonuses")
                            {   // Liste die anderen Boni
                                int idOthers = Unit.xml_config.GetGroupId("OTHERS");
                                Debug.Assert(idOthers >= 0);
                                for (i = 0; i < Unit.xml_config.nBonuses; i++)
                                {
                                    if ((Unit.xml_config.arBonuses[i].idGroup == idOthers) && (Unit.xml_config.arBonuses[i].arAttributes.Length == 1))
                                    {   // Werte für Sinnesschärfe direkt nicht anzeigen
                                        int bid = Unit.xml_config.arBonuses[i].arAttributes[0] & 0xfff;
                                        if ((Unit.player.Attributes.Value[bid] > 0) && bVisible[ifLevel])
                                        {
                                            strText.Add((Unit.player.Attributes.Value[bid]).ToString() + " " + Unit.xml_config.arAttributes[bid].Name);
                                        }
                                    }
                                }
                            }
                            else if (strName == "materials")
                            {
                                string strTemp = strTag.Substring(iPos, Math.Min(99, strTag.Length - iPos));
                                if (strTemp == "gemlist")
                                {
                                    int[] arGemList = new int[Unit.xml_config.nBonuses * 10];
                                    Debug.Assert(arGemList != null);
                                    for (i = Unit.xml_config.nBonuses * 10; (i--) > 0;)
                                    {
                                        arGemList[i] = 0;
                                    }
                                    for (int p = 0; p < 10; p++)
                                    {
                                        if (Unit.player.ItemType[p] == EItemType.Crafted)
                                        {
                                            for (i = 0; i < Unit.player.nItemEffects[p]; i++)
                                            {
                                                int bid = Unit.player.ItemEffect[p][i];
                                                if (bid >= 0 && i < 4)
                                                {
                                                    int val = Unit.player.EffectValue[p][i];
                                                    // Effektlevel besorgen
                                                    for (int j = 0; j < 10; j++)
                                                    {
                                                        if (Unit.xml_config.arBonuses[bid].Gemvalue[j] == val)
                                                        {
                                                            arGemList[bid * 10 + j]++;
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // Gems ausgeben
                                    for (i = 0; i < Unit.xml_config.nBonuses; i++)
                                    {
                                        for (int j = 0; j < 10; j++)
                                        {
                                            if (arGemList[i * 10 + j] > 0)
                                            {
                                                if (bVisible[ifLevel])
                                                {
                                                    strText.Add((arGemList[i * 10 + j]).ToString() + " " + Unit.xml_config.arBonuses[i].GemName + " (" + Unit.xml_config.arMaterials[Unit.xml_config.GetMaterialId("GEMS")].arLevel[j].GemPrefix + ")");
                                                }
                                            }
                                        }
                                    }
                                    arGemList = null;
                                }
                                else
                                {
                                    int[]       Gems = new int[10]; // Zähler für die Gems
                                    TStringList sGemList;
                                    sGemList = new TStringList();
                                    // Lösche die Zählvariablen
                                    for (i = 0; i < Unit.xml_config.nIngredients; i++)
                                    {
                                        Unit.xml_config.arIngredients[i].Count[0] = 0;
                                    }
                                    for (i = 0; i < 10; i++)
                                    {
                                        Gems[i] = 0;
                                    }
                                    for (int p = 0; p < 10; p++)
                                    {
                                        if (Unit.player.ItemType[p] == EItemType.Crafted)
                                        {
                                            for (i = 0; i < Unit.player.nItemEffects[p]; i++)
                                            {
                                                int bid = Unit.player.ItemEffect[p][i];
                                                if (bid >= 0 && i < 4)
                                                {
                                                    int val = Unit.player.EffectValue[p][i];
                                                    // Gemlevel bestimmen
                                                    int gemlevel = -1;
                                                    for (int j = 0; j < 10; j++)
                                                    {
                                                        if (Unit.xml_config.arBonuses[bid].Gemvalue[j] == val)
                                                        {
                                                            gemlevel = j;
                                                            break;
                                                        }
                                                    }
                                                    Debug.Assert(gemlevel >= 0);
                                                    // Besorge zu dem gemlevel die Anzahl an Stäuben und Flüssigkeiten
                                                    int dusts   = Unit.xml_config.arBonuses[bid].DustAmount[gemlevel];
                                                    int liquids = Unit.xml_config.arBonuses[bid].LiquidAmount[gemlevel];
                                                    // Jetzt wissen wir welches Gem gebraucht wird
                                                    int dust = Unit.xml_config.arBonuses[bid].GemDust;
                                                    Gems[gemlevel] += Unit.xml_config.arBonuses[bid].GemAmount[gemlevel] + (Unit.player.Remakes[p][i] * Unit.xml_config.arBonuses[bid].GemAmount[gemlevel]);
                                                    Unit.xml_config.arIngredients[dust].Count[0] += (Unit.player.Remakes[p][i] + 1) * dusts;
                                                    for (int j = 0; j < Unit.xml_config.arBonuses[bid].nLiquids; j++)
                                                    {
                                                        Unit.xml_config.arIngredients[Unit.xml_config.arBonuses[bid].GemLiquids[j]].Count[0] += (Unit.player.Remakes[p][i] + 1) * liquids;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // Die Ausgabe ist jetzt abhängig von der angeforderten Liste
                                    if (strTemp == "gems")
                                    {
                                        int Gem = Unit.xml_config.GetMaterialId("GEMS");
                                        for (i = 0; i < 10; i++)
                                        {
                                            if ((Gems[i] > 0) && bVisible[ifLevel])
                                            {
                                                strText.Add((Gems[i]).ToString() + " " + Unit.xml_config.arMaterials[Gem].arLevel[i].Name + " " + _("Juwel"));
                                            }
                                        }
                                    }
                                    else if (strTemp == "dusts")
                                    {
                                        for (i = 0; i < Unit.xml_config.nIngredients; i++)
                                        {
                                            if (Unit.xml_config.arIngredients[i].bDust && (Unit.xml_config.arIngredients[i].Count[0] > 0) && bVisible[ifLevel])
                                            {
                                                strText.Add((Unit.xml_config.arIngredients[i].Count[0]).ToString() + " " + Unit.xml_config.arIngredients[i].Name);
                                            }
                                        }
                                    }
                                    else if (strTemp == "liquids")
                                    {
                                        for (i = 0; i < Unit.xml_config.nIngredients; i++)
                                        {
                                            if (!Unit.xml_config.arIngredients[i].bDust && (Unit.xml_config.arIngredients[i].Count[0] > 0) && bVisible[ifLevel])
                                            {
                                                strText.Add((Unit.xml_config.arIngredients[i].Count[0]).ToString() + " " + Unit.xml_config.arIngredients[i].Name);
                                            }
                                        }
                                    }
                                    sGemList = null;
                                }
                            }
                            else if (PieceStat(strTag, out strInsert, ref iPos) > 0)
                            {
                            }    // Hier muß nichts mehr gemacht werden
                            else // Kein bekannter Tag, also den tag im orginal ausgeben
                            {
                                strInsert = "<" + strTag + '>';
                            }
                            if (aid >= 0)
                            {
                                strInsert = Unit.player.Attributes.Value[aid].ToString();
                            }
                            if (bVisible[ifLevel])
                            {
                                if (iPos < strTag.Length)
                                {       // Gibt eine Feldlänge
                                    int iLen = strTag.Substring(iPos, Math.Min(2, strTag.Length - iPos)).ToIntDef(0);
                                    if (strInsert.Length < iLen)
                                    {
                                        strLine += new string(' ', iLen - strInsert.Length);
                                    }
                                }
                                strLine += strInsert;
                            }
                            bTag = false;
                        }
                        else
                        {       // Im Tag
                            if (cCur == ' ')
                            {
                                bName = false;
                            }
                            strTag += cCur;
                            if (bName)
                            {
                                strName += cCur;
                            }
                        }
                    }
                    else        // Wir sind im normalen Text
                    {
                        if (cCur == '<')
                        {
                            bTag    = true;
                            bName   = true;
                            strTag  = "";
                            strName = "";
                        }
                        else if (cCur == '\n')
                        {
                            if (bVisible[ifLevel] && !bConditional)
                            {
                                strText.Add(strLine);
                            }
                            strLine      = "";
                            bConditional = false;
                        }
                        else
                        if (bVisible[ifLevel])
                        {
                            strLine += cCur;
                        }
                    }
                }
                tbReport.Lines = strText.Strings.ToArray();
                strText        = null;
            }
            catch (Exception)
            {
                Utils.DebugPrint("Es ist ein Fehler in TfrmReport::DoReport aufgetreten!");
            }
        }