Exemplo n.º 1
0
        private static void InitFactionTemplateDBC()
        {
            var dbcRdr =
                new MappedDBCReader <FactionTemplateEntry, FactionTemplateConverter>(
                    RealmServerConfiguration.GetDBCFile(WCellConstants.DBC_FACTION_TEMPLATES));

            foreach (var templ in dbcRdr.Entries.Values)
            {
                FactionTplEntries[templ.Id] = templ;

                if (templ.FactionId == 0)
                {
                    // some templates do not have an actual faction
                    continue;
                }

                var entry   = FactionEntries[templ.FactionId];
                var faction = new Faction(entry, templ);
                ArrayUtil.Set(ref ByTemplateId, templ.Id, faction);

                // there are several templates for one faction
                if (Get(templ.FactionId) != null)
                {
                    continue;
                }

                ArrayUtil.Set(ref ById, (uint)entry.Id, faction);

                if (entry.FactionIndex > 0)
                {
                    ArrayUtil.Set(ref ByReputationIndex, (uint)entry.FactionIndex, faction);
                }
            }

            // add Factions for Races and set their faction-group
            Faction fac;

            ByRace[(uint)RaceId.Human] = fac = ById[(uint)FactionId.PLAYERHuman];
            fac.SetAlliancePlayer();

            ByRace[(uint)RaceId.Dwarf] = fac = ById[(uint)FactionId.PLAYERDwarf];
            fac.SetAlliancePlayer();

            ByRace[(uint)RaceId.NightElf] = fac = ById[(uint)FactionId.PLAYERNightElf];
            fac.SetAlliancePlayer();

            ByRace[(uint)RaceId.Gnome] = fac = ById[(uint)FactionId.PLAYERGnome];
            fac.SetAlliancePlayer();

            ByRace[(uint)RaceId.Draenei] = fac = ById[(uint)FactionId.PLAYERDraenei];
            fac.SetAlliancePlayer();


            ByRace[(uint)RaceId.Orc] = fac = ById[(uint)FactionId.PLAYEROrc];
            fac.SetHordePlayer();

            ByRace[(uint)RaceId.Undead] = fac = ById[(uint)FactionId.PLAYERUndead];
            fac.SetHordePlayer();

            ByRace[(uint)RaceId.Tauren] = fac = ById[(uint)FactionId.PLAYERTauren];
            fac.SetHordePlayer();

            ByRace[(uint)RaceId.Troll] = fac = ById[(uint)FactionId.PLAYERTroll];
            fac.SetHordePlayer();

            ByRace[(uint)RaceId.BloodElf] = fac = ById[(uint)FactionId.PLAYERBloodElf];
            fac.SetHordePlayer();

            foreach (var faction in ById)
            {
                if (faction != null)
                {
                    faction.Init();
                    if (faction.Entry.ParentId != FactionId.None)
                    {
                        var parent = Get(faction.Entry.ParentId);
                        // some factions are pointing to invalid other factions (so we have to use TryGetValue)
                        if (parent != null)
                        {
                            parent.Children.Add(faction);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
		private static void InitFactionTemplateDBC()
		{
			var dbcRdr =
				new MappedDBCReader<FactionTemplateEntry, FactionTemplateConverter>(
					RealmServerConfiguration.GetDBCFile(WCellDef.DBC_FACTION_TEMPLATES));

			foreach (var templ in dbcRdr.Entries.Values)
			{
				FactionTplEntries[templ.Id] = templ;

				if (templ.FactionId == 0)
				{
					// some templates do not have an actual faction
					continue;
				}

				var entry = FactionEntries[templ.FactionId];
				var faction = new Faction(entry, templ);
				ArrayUtil.Set(ref ByTemplateId, templ.Id, faction);

				// there are several templates for one faction
				if (Get(templ.FactionId) != null)
				{
					continue;
				}

				ArrayUtil.Set(ref ById, (uint)entry.Id, faction);

				if (entry.FactionIndex > 0)
				{
					ArrayUtil.Set(ref ByReputationIndex, (uint)entry.FactionIndex, faction);
				}
			}

			// add Factions for Races and set their faction-group
			Faction fac;
			ByRace[(uint)RaceId.Human] = fac = ById[(uint)FactionId.PLAYERHuman];
			fac.SetAlliancePlayer();

			ByRace[(uint)RaceId.Dwarf] = fac = ById[(uint)FactionId.PLAYERDwarf];
			fac.SetAlliancePlayer();

			ByRace[(uint)RaceId.NightElf] = fac = ById[(uint)FactionId.PLAYERNightElf];
			fac.SetAlliancePlayer();

			ByRace[(uint)RaceId.Gnome] = fac = ById[(uint)FactionId.PLAYERGnome];
			fac.SetAlliancePlayer();

			ByRace[(uint)RaceId.Draenei] = fac = ById[(uint)FactionId.PLAYERDraenei];
			fac.SetAlliancePlayer();


			ByRace[(uint)RaceId.Orc] = fac = ById[(uint)FactionId.PLAYEROrc];
			fac.SetHordePlayer();

			ByRace[(uint)RaceId.Undead] = fac = ById[(uint)FactionId.PLAYERUndead];
			fac.SetHordePlayer();

			ByRace[(uint)RaceId.Tauren] = fac = ById[(uint)FactionId.PLAYERTauren];
			fac.SetHordePlayer();

			ByRace[(uint)RaceId.Troll] = fac = ById[(uint)FactionId.PLAYERTroll];
			fac.SetHordePlayer();

			ByRace[(uint)RaceId.BloodElf] = fac = ById[(uint)FactionId.PLAYERBloodElf];
			fac.SetHordePlayer();

			foreach (var faction in ById)
			{
				if (faction != null)
				{
					faction.Init();
					if (faction.Entry.ParentId != FactionId.None)
					{
						var parent = Get(faction.Entry.ParentId);
						// some factions are pointing to invalid other factions (so we have to use TryGetValue)
						if (parent != null)
						{
							parent.Children.Add(faction);
						}
					}
				}
			}
		}