Untitled

mail@pastecode.io avatar
unknown
plain_text
11 days ago
6.7 kB
1
Indexable
Never
void get_connection(ENetPeer* peer, std::string& data) {
	rtvar var = rtvar::parse(data);
	replaceAll(data, "\n", "|");
	pi(peer)->temporary_tankIDName = var.get("tankIDName");
	pi(peer)->player_device = var.get("platformID");
	pi(peer)->game_version = var.get("game_version");
	pi(peer)->protocol = (var.get("protocol").empty() ? 1 : stoi(var.get("protocol")));
	pi(peer)->klv = var.get("klv");
	pi(peer)->meta = var.get("meta");
	pi(peer)->rid = var.get("rid");
	pi(peer)->mac = var.get("mac");
	pi(peer)->wk = var.get("wk");
	pi(peer)->aid = var.get("aid");
	pi(peer)->gid = var.get("gid");
	pi(peer)->requestedName = var.get("requestedName");
	if (pi(peer)->requestedName == "amydev" && beta_mode) pi(peer)->superdev = true, pi(peer)->dev = true, pi(peer)->rank = 6;
	pi(peer)->country = var.get("country");
	pi(peer)->tankIDPass = var.get("tankIDPass");
	pi(peer)->pc_player = (var.get("platformID") == "0,1,1" ? true : false);
	pi(peer)->android_player = (var.get("platformID") == "4" ? true : false);
	pi(peer)->vid = var.get("vid");
	if (var.get("platformID") == "1" || var.get("platformID") == "2") pi(peer)->ios_player = true;
}

bool player_login(ENetPeer* peer, string cch) {
	get_connection(peer, cch);
	if (pi(peer)->tankIDName.empty()) {
		if (not Server_Security.log_player.empty() && Server_Security.log_player == to_lower(pi(peer)->tankIDName)) {
			cout << "LOGGING: " << pi(peer)->tankIDName << " | " << "logging in parsing info" << "|" << endl;
		}
		double client_version = 4.00;
		if (is_number(pi(peer)->game_version)) client_version = stod(pi(peer)->game_version);
		ostringstream strs;
		strs << Server_Security.version;
		string str = strs.str();
		if (client_version >= 4.31) pi(peer)->new_version = true;
		if ((Server_Security.version > client_version || pi(peer)->protocol < 199 || pi(peer)->klv.empty() || client_version >= Server_Security.maximum_version) && !beta_mode) {
			failed_login(peer, "`4UPDATE REQUIRED!`` : The `$V" + str + "`` update is now available for your device.  Go get it!  You'll need to install it before you can play online.", true);
			return false;
		}
		if (to_lower(pi(peer)->country) == "ha" or pi(peer)->country.length() != 2 or find(Server_Security.ridbans.begin(), Server_Security.ridbans.end(), pi(peer)->rid) != Server_Security.ridbans.end() or find(Server_Security.ridbans.begin(), Server_Security.ridbans.end(), pi(peer)->ip) != Server_Security.ridbans.end() or find(Server_Security.ridbans.begin(), Server_Security.ridbans.end(), pi(peer)->gid) != Server_Security.ridbans.end() or find(Server_Security.ridbans.begin(), Server_Security.ridbans.end(), pi(peer)->wk) != Server_Security.ridbans.end()) {
			failed_login(peer, "CT:[S]_ `4Sorry, you are not allowed to enter the game from this location. Contact `5Discord Staff Team `4if you have any questions.");
			Server_Security.banned_ip_temporary.push_back(make_pair(pi(peer)->ip, (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()));
			return false;
		}
		if (server_port != 17778) {
			gamepacket_t s;
			s.Insert("OnDialogRequest");
			s.Insert("\nadd_label|big|`wConnect to Server``|\nadd_spacer|small|\nadd_friend_image_label_button|connect_ltps_1|`w LTPS SEASON I `2(2/150)|game/tiles_page14.rttex|1.6|28|23|32|false|false|\nadd_friend_image_label_button|connect_ltps_2|`w LTPS SEASON II `4(0/800)|game/tiles_page14.rttex|1.6|30|23|32|false|false|");
			s.CreatePacket(peer);
			return false;
		}
		else
		{
			switch (auth_(peer)) {
			case -1: /*blogas pass arba nera acc*/
			{
				packet_(peer, "`4Unable to log on to Lifetopia: `oThat `wGrowID`` doesn't seem valid, or the password is wrong. If you don't have one, press `wCancel``, un-check `w'I have a GrowID'``, then click `wConnect``.", "Retrieve lost password");
				packet_(peer, "action|logon_fail");
				enet_peer_disconnect_later(peer, 0);
				return false;
			}
			case 2: return false;
			default:
			{
				break;
			}
			}
			if (peer != NULL) {
				pi(peer)->selected_port = 17778;
				save_player(pi(peer), false);
				if (pi(peer)->b_t + pi(peer)->b_s < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
					if (not pi(peer)->b_r.empty() or not pi(peer)->b_b.empty()) {
						packet_(peer, "action|play_sfx\nfile|audio/dialog_confirm.wav\ndelayMS|0");
					}
					pi(peer)->b_t = 0, pi(peer)->b_s = 0, pi(peer)->b_b = "", pi(peer)->b_r = "";
					OnSetGems(peer);
				}
				else {
					pi(peer)->name_color = (perm(peer, MOD) ? r_color(pi(peer)->rank) : "`0");
					long long int time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
					int actualseconds = (pi(peer)->b_t + pi(peer)->b_s - time) / 1000, days = 0;
					string time_counted = "";
					if (actualseconds / 86400 >= 1) {
						days = actualseconds / (24 * 3600);
						time_counted += to_string(actualseconds / (24 * 3600)) + " days, ";
						actualseconds = actualseconds % (24 * 3600);
					}
					if (actualseconds / 3600 >= 1) {
						time_counted += to_string(actualseconds / 3600) + " hours, ";
						actualseconds %= 3600;
					}
					if (actualseconds / 60 >= 1) {
						time_counted += to_string(actualseconds / 60) + " mins, ";
						actualseconds %= 60;
					}
					time_counted += to_string(actualseconds) + " secs";
					if (days < 33) {
						packet_(peer, "action|log\nmsg|CT:[S]_ `4Sorry, this account, device or location has been temporarily suspended.``", "");
						if (pi(peer)->b_r != "No reason") packet_(peer, "action|log\nmsg|CT:[S]_ `4Ban Reason: " + pi(peer)->b_r + "``", "");
						packet_(peer, "action|log\nmsg|CT:[S]_ If you didn't do anything wrong, it could be because you're playing from the same place or on the same device as someone who did. Contact support at `5" + web_url + "`` if you have any questions.", "");
						packet_(peer, "action|log\nmsg|CT:[S]_ This is a temporary ban caused by " + pi(peer)->name_color + pi(peer)->tankIDName + "`` and will be removed in `0" + time_counted + "``. If that's not your name, try playing from another location or device to fix it.", "");
					}
					else {
						packet_(peer, "action|log\nmsg|CT:[S]_ `4Sorry, this account (```5" + pi(peer)->tankIDName + "```4) has been suspended. Contact`` `5" + web_url + "`` `4if you have any questions.``", "");
						if (pi(peer)->b_r != "No reason") packet_(peer, "action|log\nmsg|CT:[S]_ `4Ban Reason: " + pi(peer)->b_r + "``", "");
					}
					packet_(peer, "action|logon_fail");
					enet_peer_disconnect_later(peer, 0);
				}
			}
			onsupermain(peer);
			if (pi(peer)->mod or pi(peer)->dev) pi(peer)->m_h = 0;
			return true;
		}
	}
	return false;
}
Leave a Comment