Пример #1
0
	World LoginParser::parse_world(InPacket& recv)
	{
		int8_t wid = recv.read_byte();
		if (wid == -1)
			return{ {}, {}, {}, 0, 0, wid };

		std::string name = recv.read_string();
		uint8_t flag = recv.read_byte();
		std::string message = recv.read_string();

		recv.skip(5);

		std::vector<int32_t> chloads;
		uint8_t channelcount = recv.read_byte();
		for (uint8_t i = 0; i < channelcount; ++i)
		{
			recv.read_string(); // channel name
			chloads.push_back(recv.read_int());
			recv.skip(1);
			recv.skip(2);
		}

		recv.skip(2);

		return{ name, message, chloads, channelcount, flag, wid };
	}
Пример #2
0
	void SetfieldHandler::parse_questlog(InPacket& recv, Questlog& quests) const
	{
		int16_t size = recv.read_short();
		for (int16_t i = 0; i < size; i++)
		{
			int16_t qid = recv.read_short();
			std::string qdata = recv.read_string();
			if (quests.is_started(qid))
			{
				int16_t qidl = quests.get_last_started();
				quests.add_in_progress(qidl, qid, qdata);
				i--;
			}
			else
			{
				quests.add_started(qid, qdata);
			}
		}

		std::map<int16_t, int64_t> completed;
		size = recv.read_short();
		for (int16_t i = 0; i < size; i++)
		{
			int16_t qid = recv.read_short();
			int64_t time = recv.read_long();
			quests.add_completed(qid, time);
		}
	}
Пример #3
0
	void SetfieldHandler::parseareainfo(InPacket& recv) const
	{
		std::map<int16_t, std::string> areainfo;
		int16_t arsize = recv.read_short();
		for (int16_t i = 0; i < arsize; i++)
		{
			int16_t area = recv.read_short();
			areainfo[area] = recv.read_string();
		}
	}
Пример #4
0
	void SkillMacrosHandler::handle(InPacket& recv) const
	{
		uint8_t size = recv.read_byte();
		for (uint8_t i = 0; i < size; i++)
		{
			recv.read_string(); // name
			recv.read_byte(); // 'shout' byte
			recv.read_int(); // skill 1
			recv.read_int(); // skill 2
			recv.read_int(); // skill 3
		}
	}
Пример #5
0
	void CharnameResponseHandler::handle(InPacket& recv) const
	{
		// Read the name and if it is already in use.
		std::string name = recv.read_string();
		bool used = recv.read_bool();

		if (used)
		{
			UI::get().emplace<UILoginNotice>(UILoginNotice::NAME_IN_USE);
		}

		// Notify the character creation screen.
		if (auto charcreation = UI::get().get_element<UICharcreation>())
			charcreation->send_naming_result(used);

		UI::get().enable();
	}
Пример #6
0
	void SetfieldHandler::set_field(InPacket& recv) const
	{
		recv.skip(23);

		int32_t cid = recv.read_int();

		const CharEntry& playerentry = Session::get().getlogin().getcharbyid(cid);
		if (playerentry.cid != cid)
		{
			Console::get().print("Nonexisting cid: " + std::to_string(cid));
		}

		Stage::get().loadplayer(playerentry);

		Session::get().getlogin().parsestats(recv);

		Player& player = Stage::get().getplayer();

		recv.read_byte(); // 'buddycap'
		if (recv.read_bool())
		{
			recv.read_string(); // 'linkedname'
		}

		parse_inventory(recv, player.getinvent());
		parse_skillbook(recv, player.getskills());
		parse_questlog(recv, player.getquests());
		parseminigame(recv);
		parsering1(recv);
		parsering2(recv);
		parsering3(recv);
		parsetelerock(recv, player.gettrock());
		parsemonsterbook(recv, player.getmonsterbook());
		parsenewyear(recv);
		parseareainfo(recv);

		recv.skip(10);

		player.recalcstats(true);

		stagetransition(player.getstats().getportal(), player.getstats().getmapid());

		Sound(Sound::GAMESTART).play();

		UI::get().changestate(UI::GAME);
	}
Пример #7
0
	Account LoginParser::parse_account(InPacket & recv)
	{
		Account account;

		recv.skip(2);
		account.accid = recv.read_int();
		account.female = recv.read_bool();
		recv.read_bool(); //is admin
		account.gmlevel = recv.read_byte();
		recv.skip(1);
		account.name = recv.read_string();
		recv.skip(1);
		account.muted = recv.read_bool();
		recv.read_long(); //muted until
		recv.read_long(); //creation date
		recv.skip(4);
		account.pin = recv.read_short();

		return account;
	}
Пример #8
0
	void CharnameResponseHandler::handle(InPacket& recv) const
	{
		// Read the name and if it is already in use.
		std::string name = recv.read_string();
		bool used = recv.read_bool();

		if (used)
		{
			UI::get().add(
				ElementTag<UILoginNotice, UILoginNotice::Message>(
					UILoginNotice::NAME_IN_USE
					)
			);
		}

		// Notify character creation screen.
		UI::get().with_element<UICharcreation>([&used](auto& cc) {
			cc.nameresult(used);
		});

		UI::get().enable();
	}