public void Serialize() { var test = new MabiDictionary(); test.SetBool("a bool", true); test.SetByte("a byte", 1); test.SetShort("a short", 2); test.SetInt("an int", 3); test.SetFloat("a float", 4); test.SetString("a string", "five, special chars :;"); var test2 = test.ToString(); Assert.Equal("a bool:b:1;a byte:1:1;a short:2:2;an int:4:3;a float:f:4;a string:s:five, special chars %C%S;", test2); }
public void ChannelCharacterInfoRequest(ChannelClient client, Packet packet) { var creature = client.GetCreatureSafe(packet.Id); if (creature.Master != null) { var pos = creature.GetPosition(); Send.SpawnEffect(SpawnEffect.Pet, creature.RegionId, pos.X, pos.Y, creature.Master, creature); } // Infamous 5209, aka char info Send.ChannelCharacterInfoRequestR(client, creature); // Send any necessary "feature enabled" packets, grant extra items, update quests, etc. ChannelServer.Instance.Events.OnCreatureConnecting(creature); // Special treatment for pets if (creature.Master != null) { // Send vehicle info to make mounts mountable if (creature.RaceData.VehicleType > 0) { Send.VehicleInfo(creature); } } var now = DateTime.Now; // Update last login creature.LastLogin = now; // Age check var lastSaturday = ErinnTime.Now.GetLastSaturday(); var lastAging = creature.LastAging; var diff = (lastSaturday - lastAging).TotalDays; if (lastAging < lastSaturday) { creature.AgeUp((short)(1 + diff / 7)); } // Name/Chat color conditions if (creature.Vars.Perm["NameColorEnd"] != null) { var dt = (DateTime)creature.Vars.Perm["NameColorEnd"]; if (now > dt) { creature.Vars.Perm["NameColorIdx"] = null; creature.Vars.Perm["NameColorEnd"] = null; } } if (creature.Vars.Perm["ChatColorEnd"] != null) { var dt = (DateTime)creature.Vars.Perm["ChatColorEnd"]; if (now > dt) { creature.Vars.Perm["ChatColorIdx"] = null; creature.Vars.Perm["ChatColorEnd"] = null; } } if (creature.Vars.Perm["NameColorIdx"] != null) { var extra = new MabiDictionary(); extra.SetInt("IDX", (int)creature.Vars.Perm["NameColorIdx"]); creature.Conditions.Activate(ConditionsB.NameColorChange, extra); } if (creature.Vars.Perm["ChatColorIdx"] != null) { var extra = new MabiDictionary(); extra.SetInt("IDX", (int)creature.Vars.Perm["ChatColorIdx"]); creature.Conditions.Activate(ConditionsB.ChatColorChange, extra); } // Chat sticker hack // You don't see your own chat stickers on Aura without this packet // for unknown reasons. if (creature.Vars.Perm["ChatStickerId"] != null) { var sticker = (ChatSticker)creature.Vars.Perm["ChatStickerId"]; var end = (DateTime)creature.Vars.Perm["ChatStickerEnd"]; if (now < end) { Send.ChatSticker(creature, sticker, end); } } // Update Pon Send.PointsUpdate(creature, creature.Points); // Send UrlUpdate packets? // - UrlUpdateChronicle // - UrlUpdateAdvertise // - UrlUpdateGuestbook // - UrlUpdatePvp // - UrlUpdateDungeonBoard // Update dead menu, in case creature is dead creature.DeadMenu.Update(); // Any extra ChannelInfo initialization from scripts // Actual first update of features ChannelServer.Instance.Events.OnCreatureConnected(creature); }
public void ChannelCharacterInfoRequest(ChannelClient client, Packet packet) { var creature = client.GetCreatureSafe(packet.Id); if (creature.Master != null) { var pos = creature.GetPosition(); Send.SpawnEffect(SpawnEffect.Pet, creature.RegionId, pos.X, pos.Y, creature.Master, creature); } // Infamous 5209, aka char info Send.ChannelCharacterInfoRequestR(client, creature); // Special treatment for pets if (creature.Master != null) { // Send vehicle info to make mounts mountable if (creature.RaceData.VehicleType > 0) { Send.VehicleInfo(creature); } } var playerCreature = creature as PlayerCreature; if (playerCreature != null) { // Update last login playerCreature.LastLogin = DateTime.Now; // Age check var lastSaturday = ErinnTime.Now.GetLastSaturday(); var lastAging = playerCreature.LastAging; var diff = (lastSaturday - lastAging).TotalDays; if (lastAging < lastSaturday) { playerCreature.AgeUp((short)(1 + diff / 7)); } // Name/Chat color conditions if (creature.Vars.Perm["NameColorEnd"] != null) { var dt = (DateTime)creature.Vars.Perm["NameColorEnd"]; if (DateTime.Now > dt) { creature.Vars.Perm["NameColorIdx"] = null; creature.Vars.Perm["NameColorEnd"] = null; } } if (creature.Vars.Perm["ChatColorEnd"] != null) { var dt = (DateTime)creature.Vars.Perm["ChatColorEnd"]; if (DateTime.Now > dt) { creature.Vars.Perm["ChatColorIdx"] = null; creature.Vars.Perm["ChatColorEnd"] = null; } } if (creature.Vars.Perm["NameColorIdx"] != null) { var extra = new MabiDictionary(); extra.SetInt("IDX", (int)creature.Vars.Perm["NameColorIdx"]); creature.Conditions.Activate(ConditionsB.NameColorChange, extra); } if (creature.Vars.Perm["ChatColorIdx"] != null) { var extra = new MabiDictionary(); extra.SetInt("IDX", (int)creature.Vars.Perm["ChatColorIdx"]); creature.Conditions.Activate(ConditionsB.ChatColorChange, extra); } } }
public void ChangeNameColor(ChannelClient client, Packet packet) { var creature = client.GetCreatureSafe(packet.Id); // Check item id if (creature.Temp.NameColorItemEntityId == 0) { Log.Warning("ChangeNameColor: Creature '{0:X16}' sent packet while item id is 0.", creature.EntityId); return; } // Check item var item = creature.Inventory.GetItem(creature.Temp.NameColorItemEntityId); if (item == null) { Log.Warning("ChangeNameColor: Creature '{0:X16}' doesn't have the item.", creature.EntityId); return; } // Figure out what to change var bothChange = item.HasTag("/name_chatting_color_change/"); var nameChange = bothChange || item.HasTag("/name_color_change/"); var chatChange = bothChange || item.HasTag("/chatting_color_change/"); if (!nameChange && !chatChange) { Log.Warning("ChangeNameColor: Creature '{0:X16}' tried to use invalid item.", creature.EntityId); return; } creature.Temp.NameColorItemEntityId = 0; // "Calculate" color // It's currently unknown how the client gets the colors, the index // sent to the client is not the slot the wheel lands on, and it's // not a color from the color table. Might be hardcoded. var idx = -1; switch (creature.Temp.ColorWheelResult) { case 1: idx = 28; break; case 2: case 3: idx = 14; break; case 4: idx = 13; break; case 5: idx = 11; break; case 6: idx = 1; break; case 7: idx = 6; break; case 8: idx = 26; break; case 9: idx = 5; break; case 10: idx = 25; break; case 11: idx = 1; break; case 12: idx = 11; break; case 13: idx = 4; break; case 14: idx = 3; break; case 15: idx = 11; break; case 16: idx = 18; break; case 17: idx = 22; break; case 18: idx = 10; break; case 19: idx = 24; break; case 20: idx = 27; break; case 21: idx = 12; break; case 22: idx = 23; break; case 23: idx = 19; break; case 24: idx = 3; break; case 25: idx = 16; break; case 26: idx = 8; break; case 27: idx = 30; break; case 28: idx = 2; break; case 29: idx = 20; break; case 30: idx = 21; break; case 31: idx = 15; break; case 32: idx = 9; break; default: Log.Warning("ChangeNameColor: Calculating color failed, result: {0}.", creature.Temp.ColorWheelResult); return; } // Remove item from inv creature.Inventory.Remove(item); // Expiration apparently varies based on the item, // no expiration time can be found in the db. var end = DateTime.Now.AddDays(item.Info.Id != 85563 ? 7 : 30); // Set conditions that modify the colors var extra = new MabiDictionary(); extra.SetInt("IDX", idx); // Activate name color change if (nameChange) { creature.Conditions.Activate(ConditionsB.NameColorChange, extra); creature.Vars.Perm["NameColorIdx"] = idx; creature.Vars.Perm["NameColorEnd"] = end; } // Activate chat color change if (chatChange) { creature.Conditions.Activate(ConditionsB.ChatColorChange, extra); creature.Vars.Perm["ChatColorIdx"] = idx; creature.Vars.Perm["ChatColorEnd"] = end; } // Notice if (bothChange) { Send.Notice(creature, NoticeType.Middle, Localization.Get("Your name and chat text colors have changed.")); } else if (nameChange) { Send.Notice(creature, NoticeType.Middle, Localization.Get("Your name color has changed.")); } else if (chatChange) { Send.Notice(creature, NoticeType.Middle, Localization.Get("Your chat text color has changed.")); } }
public void ChannelCharacterInfoRequest(ChannelClient client, Packet packet) { var creature = client.GetCreatureSafe(packet.Id); if (creature.Master != null) { var pos = creature.GetPosition(); Send.SpawnEffect(SpawnEffect.Pet, creature.RegionId, pos.X, pos.Y, creature.Master, creature); } // Infamous 5209, aka char info Send.ChannelCharacterInfoRequestR(client, creature); // Special treatment for pets if (creature.Master != null) { // Send vehicle info to make mounts mountable if (creature.RaceData.VehicleType > 0) { Send.VehicleInfo(creature); } } var now = DateTime.Now; // Update last login creature.LastLogin = now; // Age check var lastSaturday = ErinnTime.Now.GetLastSaturday(); var lastAging = creature.LastAging; var diff = (lastSaturday - lastAging).TotalDays; if (lastAging < lastSaturday) { creature.AgeUp((short)(1 + diff / 7)); } // Name/Chat color conditions if (creature.Vars.Perm["NameColorEnd"] != null) { var dt = (DateTime)creature.Vars.Perm["NameColorEnd"]; if (now > dt) { creature.Vars.Perm["NameColorIdx"] = null; creature.Vars.Perm["NameColorEnd"] = null; } } if (creature.Vars.Perm["ChatColorEnd"] != null) { var dt = (DateTime)creature.Vars.Perm["ChatColorEnd"]; if (now > dt) { creature.Vars.Perm["ChatColorIdx"] = null; creature.Vars.Perm["ChatColorEnd"] = null; } } if (creature.Vars.Perm["NameColorIdx"] != null) { var extra = new MabiDictionary(); extra.SetInt("IDX", (int)creature.Vars.Perm["NameColorIdx"]); creature.Conditions.Activate(ConditionsB.NameColorChange, extra); } if (creature.Vars.Perm["ChatColorIdx"] != null) { var extra = new MabiDictionary(); extra.SetInt("IDX", (int)creature.Vars.Perm["ChatColorIdx"]); creature.Conditions.Activate(ConditionsB.ChatColorChange, extra); } // Chat sticker hack // You don't see your own chat stickers on Aura without this packet // for unknown reasons. if (creature.Vars.Perm["ChatStickerId"] != null) { var sticker = (ChatSticker)creature.Vars.Perm["ChatStickerId"]; var end = (DateTime)creature.Vars.Perm["ChatStickerEnd"]; if (now < end) { Send.ChatSticker(creature, sticker, end); } } // Update Pon Send.PonsUpdate(creature, creature.Client.Account.Points); // Update dead menu, in case creature is dead creature.DeadMenu.Update(); }