forked from alterware/iw6-mod
		
	Compare commits
	
		
			7 Commits
		
	
	
		
			v0.0.1
			...
			cmd_line_h
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 1db89c64c6 | ||
|  | 51e831cbfe | ||
|  | 50aa4097bb | ||
|  | e5a547650c | ||
|  | adc33983a8 | ||
|  | 27d1f61789 | ||
|  | d0003da606 | 
| @@ -82,7 +82,7 @@ namespace auth | |||||||
| 			return key; | 			return key; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		int send_connect_data_stub(game::netsrc_t sock, game::netadr_s* adr, const char* format, const int len) | 		int send_connect_data_stub(game::netsrc_t sock, game::netadr_t* adr, const char* format, const int len) | ||||||
| 		{ | 		{ | ||||||
| 			std::string connect_string(format, len); | 			std::string connect_string(format, len); | ||||||
| 			game::SV_Cmd_TokenizeString(connect_string.data()); | 			game::SV_Cmd_TokenizeString(connect_string.data()); | ||||||
| @@ -116,7 +116,7 @@ namespace auth | |||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		void direct_connect(game::netadr_s* from, game::msg_t* msg) | 		void direct_connect(game::netadr_t* from, game::msg_t* msg) | ||||||
| 		{ | 		{ | ||||||
| 			const auto offset = sizeof("connect") + 4; | 			const auto offset = sizeof("connect") + 4; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -144,7 +144,7 @@ namespace bots | |||||||
| 		{ | 		{ | ||||||
| 			bot_names_received = false; | 			bot_names_received = false; | ||||||
|  |  | ||||||
| 			game::netadr_s master{}; | 			game::netadr_t master{}; | ||||||
| 			if (server_list::get_master_server(master)) | 			if (server_list::get_master_server(master)) | ||||||
| 			{ | 			{ | ||||||
| 				console::info("Getting bots...\n"); | 				console::info("Getting bots...\n"); | ||||||
| @@ -198,9 +198,9 @@ namespace bots | |||||||
| 				parse_bot_names_from_file(); | 				parse_bot_names_from_file(); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			network::on("getbotsResponse", [](const game::netadr_s& target, const std::string& data) | 			network::on("getbotsResponse", [](const game::netadr_t& target, const std::string& data) | ||||||
| 			{ | 			{ | ||||||
| 				game::netadr_s master{}; | 				game::netadr_t master{}; | ||||||
| 				if (server_list::get_master_server(master) && !bot_names_received && target == master) | 				if (server_list::get_master_server(master) && !bot_names_received && target == master) | ||||||
| 				{ | 				{ | ||||||
| 					bot_names = utils::string::split(data, '\n'); | 					bot_names = utils::string::split(data, '\n'); | ||||||
|   | |||||||
| @@ -86,18 +86,28 @@ namespace colors | |||||||
| 			return string; | 			return string; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		size_t get_client_name_stub(const int local_client_num, const int index, char* buf, const int size, | 		size_t get_client_name_stub(const int local_client_num, const int index, char* name_buf,  | ||||||
| 		                            const size_t unk, const size_t unk2) | 									const int max_name_size, char* clan_buf, const int max_clan_size) | ||||||
| 		{ | 		{ | ||||||
| 			// CL_GetClientName (CL_GetClientNameAndClantag?) | 			// CL_GetClientNameAndClanTag (wrapper for CL_GetClientNameAndClanTagColorize) | ||||||
| 			const auto result = reinterpret_cast<size_t(*)(int, int, char*, int, size_t, size_t)>(0x1402CF790)( | 			const auto result = reinterpret_cast<size_t(*)(int, int, char*, int, char*, int)>(0x1402CF790)( | ||||||
| 				local_client_num, index, buf, size, unk, unk2); | 				local_client_num, index, name_buf, max_name_size, clan_buf, max_clan_size); | ||||||
|  |  | ||||||
| 			utils::string::strip(buf, buf, size); | 			utils::string::strip(name_buf, name_buf, static_cast<size_t>(max_name_size)); | ||||||
|  |  | ||||||
| 			return result; | 			return result; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		int clean_agent_name_stub(char* out, int max_size, const char* fmt, const char* in) | ||||||
|  | 		{ | ||||||
|  | 			// format agent overhead name like [%s] | ||||||
|  | 			const auto length = sprintf_s(out, max_size, fmt, in); | ||||||
|  |  | ||||||
|  | 			utils::string::strip(in, out, std::min(static_cast<size_t>(length), static_cast<size_t>(max_size))); | ||||||
|  |  | ||||||
|  | 			return length; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		void rb_lookup_color_stub(const char index, DWORD* color) | 		void rb_lookup_color_stub(const char index, DWORD* color) | ||||||
| 		{ | 		{ | ||||||
| 			*color = RGB(255, 255, 255); | 			*color = RGB(255, 255, 255); | ||||||
| @@ -143,6 +153,9 @@ namespace colors | |||||||
| 				// don't apply colors to overhead names | 				// don't apply colors to overhead names | ||||||
| 				utils::hook::call(0x14025CE79, get_client_name_stub); | 				utils::hook::call(0x14025CE79, get_client_name_stub); | ||||||
|  |  | ||||||
|  | 				// don't apply colors to overhead names of agents (like dogs or juggernauts) | ||||||
|  | 				utils::hook::call(0x1402CF760, clean_agent_name_stub); | ||||||
|  |  | ||||||
| 				// patch I_CleanStr | 				// patch I_CleanStr | ||||||
| 				utils::hook::jump(0x1404F63C0, i_clean_str_stub); | 				utils::hook::jump(0x1404F63C0, i_clean_str_stub); | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -194,7 +194,7 @@ namespace command | |||||||
|  |  | ||||||
| 	void add_raw(const char* name, void (*callback)()) | 	void add_raw(const char* name, void (*callback)()) | ||||||
| 	{ | 	{ | ||||||
| 		game::Cmd_AddCommandInternal(name, callback, utils::memory::get_allocator()->allocate<game::cmd_function_s>()); | 		game::Cmd_AddCommandInternal(name, callback, utils::memory::get_allocator()->allocate<game::cmd_function_t>()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void add(const char* name, const std::function<void(const params&)>& callback) | 	void add(const char* name, const std::function<void(const params&)>& callback) | ||||||
| @@ -318,7 +318,7 @@ namespace command | |||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				console::info("================================ COMMAND DUMP =====================================\n"); | 				console::info("================================ COMMAND DUMP =====================================\n"); | ||||||
| 				game::cmd_function_s* cmd = *game::cmd_functions; | 				game::cmd_function_t* cmd = *game::cmd_functions; | ||||||
| 				auto i = 0; | 				auto i = 0; | ||||||
| 				while (cmd) | 				while (cmd) | ||||||
| 				{ | 				{ | ||||||
|   | |||||||
| @@ -110,7 +110,7 @@ namespace dedicated | |||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			game::netadr_s target{}; | 			game::netadr_t target{}; | ||||||
| 			if (server_list::get_master_server(target)) | 			if (server_list::get_master_server(target)) | ||||||
| 			{ | 			{ | ||||||
| 				network::send(target, "heartbeat", "IW6"); | 				network::send(target, "heartbeat", "IW6"); | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ namespace discord | |||||||
| 					discord_presence.state = host_name; | 					discord_presence.state = host_name; | ||||||
| 					discord_presence.partyMax = party::server_client_count(); | 					discord_presence.partyMax = party::server_client_count(); | ||||||
|  |  | ||||||
| 					std::hash<game::netadr_s> hash_fn; | 					std::hash<game::netadr_t> hash_fn; | ||||||
| 					static const auto nonce = utils::cryptography::random::get_integer(); | 					static const auto nonce = utils::cryptography::random::get_integer(); | ||||||
|  |  | ||||||
| 					const auto& address = party::get_target(); | 					const auto& address = party::get_target(); | ||||||
|   | |||||||
| @@ -110,7 +110,7 @@ namespace dvar_cheats | |||||||
| 		a.jmp(0x1404F0D74); | 		a.jmp(0x1404F0D74); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	void cg_set_client_dvar_from_server(const int local_client_num, game::mp::cg_s* cg, const char* dvar_id, const char* value) | 	void cg_set_client_dvar_from_server(const int local_client_num, game::mp::cg_t* cg, const char* dvar_id, const char* value) | ||||||
| 	{ | 	{ | ||||||
| 		if (dvar_id == "cg_fov"s || dvar_id == "com_maxfps"s) | 		if (dvar_id == "cg_fov"s || dvar_id == "com_maxfps"s) | ||||||
| 		{ | 		{ | ||||||
|   | |||||||
| @@ -674,7 +674,7 @@ namespace game_console | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		game::cmd_function_s* cmd = (*game::cmd_functions); | 		game::cmd_function_t* cmd = (*game::cmd_functions); | ||||||
| 		while (cmd) | 		while (cmd) | ||||||
| 		{ | 		{ | ||||||
| 			if (cmd->name) | 			if (cmd->name) | ||||||
|   | |||||||
| @@ -133,7 +133,7 @@ namespace gameplay | |||||||
| 			return jump_height; | 			return jump_height; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		void jump_apply_slowdown_stub(game::mp::playerState_s* ps) | 		void jump_apply_slowdown_stub(game::mp::playerState_t* ps) | ||||||
| 		{ | 		{ | ||||||
| 			assert(ps->pm_flags & game::PMF_JUMPING); | 			assert(ps->pm_flags & game::PMF_JUMPING); | ||||||
|  |  | ||||||
| @@ -163,7 +163,7 @@ namespace gameplay | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		float jump_get_slowdown_friction(game::mp::playerState_s* ps) | 		float jump_get_slowdown_friction(game::mp::playerState_t* ps) | ||||||
| 		{ | 		{ | ||||||
| 			assert(ps->pm_flags & game::PMF_JUMPING); | 			assert(ps->pm_flags & game::PMF_JUMPING); | ||||||
| 			assert(ps->pm_time <= game::JUMP_LAND_SLOWDOWN_TIME); | 			assert(ps->pm_time <= game::JUMP_LAND_SLOWDOWN_TIME); | ||||||
| @@ -181,7 +181,7 @@ namespace gameplay | |||||||
| 			return 2.5f; | 			return 2.5f; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		float jump_reduce_friction_stub(game::mp::playerState_s* ps) | 		float jump_reduce_friction_stub(game::mp::playerState_t* ps) | ||||||
| 		{ | 		{ | ||||||
| 			float control; | 			float control; | ||||||
|  |  | ||||||
| @@ -199,7 +199,7 @@ namespace gameplay | |||||||
| 			return control; | 			return control; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		float jump_get_land_factor(game::mp::playerState_s* ps) | 		float jump_get_land_factor(game::mp::playerState_t* ps) | ||||||
| 		{ | 		{ | ||||||
| 			assert(ps->pm_flags & game::PMF_JUMPING); | 			assert(ps->pm_flags & game::PMF_JUMPING); | ||||||
| 			assert(ps->pm_time <= game::JUMP_LAND_SLOWDOWN_TIME); | 			assert(ps->pm_time <= game::JUMP_LAND_SLOWDOWN_TIME); | ||||||
| @@ -219,9 +219,9 @@ namespace gameplay | |||||||
|  |  | ||||||
| 		void jump_start_stub(game::pmove_t* pm, game::pml_t* pml, float height) | 		void jump_start_stub(game::pmove_t* pm, game::pml_t* pml, float height) | ||||||
| 		{ | 		{ | ||||||
| 			static_assert(offsetof(game::mp::playerState_s, groundEntityNum) == 0x70); | 			static_assert(offsetof(game::mp::playerState_t, groundEntityNum) == 0x70); | ||||||
| 			static_assert(offsetof(game::mp::playerState_s, pm_time) == 0x8); | 			static_assert(offsetof(game::mp::playerState_t, pm_time) == 0x8); | ||||||
| 			static_assert(offsetof(game::mp::playerState_s, sprintState.sprintButtonUpRequired) == 0x240); | 			static_assert(offsetof(game::mp::playerState_t, sprintState.sprintButtonUpRequired) == 0x240); | ||||||
| 			static_assert(offsetof(game::pml_t, frametime) == 0x24); | 			static_assert(offsetof(game::pml_t, frametime) == 0x24); | ||||||
| 			static_assert(offsetof(game::pml_t, walking) == 0x2C); | 			static_assert(offsetof(game::pml_t, walking) == 0x2C); | ||||||
| 			static_assert(offsetof(game::pml_t, groundPlane) == 0x30); | 			static_assert(offsetof(game::pml_t, groundPlane) == 0x30); | ||||||
| @@ -229,9 +229,9 @@ namespace gameplay | |||||||
|  |  | ||||||
| 			float factor; | 			float factor; | ||||||
| 			float velocity_sqrd; | 			float velocity_sqrd; | ||||||
| 			game::mp::playerState_s* ps; | 			game::mp::playerState_t* ps; | ||||||
|  |  | ||||||
| 			ps = static_cast<game::mp::playerState_s*>(pm->ps); | 			ps = static_cast<game::mp::playerState_t*>(pm->ps); | ||||||
|  |  | ||||||
| 			assert(ps); | 			assert(ps); | ||||||
|  |  | ||||||
| @@ -295,7 +295,7 @@ namespace gameplay | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		void pm_weapon_use_ammo_stub(game::playerState_s* ps, game::Weapon weapon, | 		void pm_weapon_use_ammo_stub(game::playerState_t* ps, game::Weapon weapon, | ||||||
| 			bool is_alternate, int amount, game::PlayerHandIndex hand) | 			bool is_alternate, int amount, game::PlayerHandIndex hand) | ||||||
| 		{ | 		{ | ||||||
| 			if (!dvars::player_sustainAmmo->current.enabled) | 			if (!dvars::player_sustainAmmo->current.enabled) | ||||||
| @@ -304,10 +304,10 @@ namespace gameplay | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		game::mp::gentity_s* weapon_rocket_launcher_fire_stub(game::mp::gentity_s* ent, game::Weapon weapon, float spread, game::weaponParms* wp, | 		game::mp::gentity_t* weapon_rocket_launcher_fire_stub(game::mp::gentity_t* ent, game::Weapon weapon, float spread, game::weaponParms* wp, | ||||||
| 			const float* gun_vel, game::mp::missileFireParms* fire_parms, bool magic_bullet) | 			const float* gun_vel, game::mp::missileFireParms* fire_parms, bool magic_bullet) | ||||||
| 		{ | 		{ | ||||||
| 			auto* result = utils::hook::invoke<game::mp::gentity_s*>(0x1403DB8A0, ent, weapon, spread, wp, gun_vel, fire_parms, magic_bullet); | 			auto* result = utils::hook::invoke<game::mp::gentity_t*>(0x1403DB8A0, ent, weapon, spread, wp, gun_vel, fire_parms, magic_bullet); | ||||||
|  |  | ||||||
| 			if (ent->client != nullptr && wp->weapDef->inventoryType != game::WEAPINVENTORY_EXCLUSIVE) | 			if (ent->client != nullptr && wp->weapDef->inventoryType != game::WEAPINVENTORY_EXCLUSIVE) | ||||||
| 			{ | 			{ | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ namespace network | |||||||
| 			return callbacks; | 			return callbacks; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		bool handle_command(game::netadr_s* address, const char* command, game::msg_t* message) | 		bool handle_command(game::netadr_t* address, const char* command, game::msg_t* message) | ||||||
| 		{ | 		{ | ||||||
| 			const auto cmd_string = utils::string::to_lower(command); | 			const auto cmd_string = utils::string::to_lower(command); | ||||||
| 			auto& callbacks = get_callbacks(); | 			auto& callbacks = get_callbacks(); | ||||||
| @@ -61,7 +61,7 @@ namespace network | |||||||
| 			a.jmp(0x1402C64EE); | 			a.jmp(0x1402C64EE); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		int net_compare_base_address(const game::netadr_s* a1, const game::netadr_s* a2) | 		int net_compare_base_address(const game::netadr_t* a1, const game::netadr_t* a2) | ||||||
| 		{ | 		{ | ||||||
| 			if (a1->type == a2->type) | 			if (a1->type == a2->type) | ||||||
| 			{ | 			{ | ||||||
| @@ -83,12 +83,12 @@ namespace network | |||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		int net_compare_address(const game::netadr_s* a1, const game::netadr_s* a2) | 		int net_compare_address(const game::netadr_t* a1, const game::netadr_t* a2) | ||||||
| 		{ | 		{ | ||||||
| 			return net_compare_base_address(a1, a2) && a1->port == a2->port; | 			return net_compare_base_address(a1, a2) && a1->port == a2->port; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		void reconnect_migrated_client(game::mp::client_t*, game::netadr_s* from, const int, const int, const char*, const char*, bool) | 		void reconnect_migrated_client(game::mp::client_t*, game::netadr_t* from, const int, const int, const char*, const char*, bool) | ||||||
| 		{ | 		{ | ||||||
| 			// This happens when a client tries to rejoin after being recently disconnected, OR by a duplicated guid | 			// This happens when a client tries to rejoin after being recently disconnected, OR by a duplicated guid | ||||||
| 			// We don't want this to do anything. It decides to crash seemingly randomly | 			// We don't want this to do anything. It decides to crash seemingly randomly | ||||||
| @@ -107,14 +107,14 @@ namespace network | |||||||
| 		get_callbacks()[utils::string::to_lower(command)] = callback; | 		get_callbacks()[utils::string::to_lower(command)] = callback; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	int dw_send_to_stub(const int size, const char* src, game::netadr_s* addr) | 	int dw_send_to_stub(const int size, const char* src, game::netadr_t* addr) | ||||||
| 	{ | 	{ | ||||||
| 		sockaddr s = {}; | 		sockaddr s = {}; | ||||||
| 		game::NetadrToSockadr(addr, &s); | 		game::NetadrToSockadr(addr, &s); | ||||||
| 		return sendto(*game::query_socket, src, size, 0, &s, 16) >= 0; | 		return sendto(*game::query_socket, src, size, 0, &s, 16) >= 0; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void send(const game::netadr_s& address, const std::string& command, const std::string& data, const char separator) | 	void send(const game::netadr_t& address, const std::string& command, const std::string& data, const char separator) | ||||||
| 	{ | 	{ | ||||||
| 		std::string packet = "\xFF\xFF\xFF\xFF"; | 		std::string packet = "\xFF\xFF\xFF\xFF"; | ||||||
| 		packet.append(command); | 		packet.append(command); | ||||||
| @@ -124,7 +124,7 @@ namespace network | |||||||
| 		send_data(address, packet); | 		send_data(address, packet); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void send_data(const game::netadr_s& address, const std::string& data) | 	void send_data(const game::netadr_t& address, const std::string& data) | ||||||
| 	{ | 	{ | ||||||
| 		if (address.type == game::NA_LOOPBACK) | 		if (address.type == game::NA_LOOPBACK) | ||||||
| 		{ | 		{ | ||||||
| @@ -136,12 +136,12 @@ namespace network | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	bool are_addresses_equal(const game::netadr_s& a, const game::netadr_s& b) | 	bool are_addresses_equal(const game::netadr_t& a, const game::netadr_t& b) | ||||||
| 	{ | 	{ | ||||||
| 		return net_compare_address(&a, &b); | 		return net_compare_address(&a, &b); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	const char* net_adr_to_string(const game::netadr_s& a) | 	const char* net_adr_to_string(const game::netadr_t& a) | ||||||
| 	{ | 	{ | ||||||
| 		if (a.type == game::NA_LOOPBACK) | 		if (a.type == game::NA_LOOPBACK) | ||||||
| 		{ | 		{ | ||||||
| @@ -286,7 +286,7 @@ namespace network | |||||||
| 				if (!game::environment::is_dedi()) | 				if (!game::environment::is_dedi()) | ||||||
| 				{ | 				{ | ||||||
| 					// we need this on the client for RCon | 					// we need this on the client for RCon | ||||||
| 					on("print", [](const game::netadr_s& address, const std::string& message) | 					on("print", [](const game::netadr_t& address, const std::string& message) | ||||||
| 					{ | 					{ | ||||||
| 						if (address != party::get_target()) | 						if (address != party::get_target()) | ||||||
| 						{ | 						{ | ||||||
|   | |||||||
| @@ -2,23 +2,23 @@ | |||||||
|  |  | ||||||
| namespace network | namespace network | ||||||
| { | { | ||||||
| 	using callback = std::function<void(const game::netadr_s&, const std::string&)>; | 	using callback = std::function<void(const game::netadr_t&, const std::string&)>; | ||||||
|  |  | ||||||
| 	void on(const std::string& command, const callback& callback); | 	void on(const std::string& command, const callback& callback); | ||||||
| 	void send(const game::netadr_s& address, const std::string& command, const std::string& data = {}, char separator = ' '); | 	void send(const game::netadr_t& address, const std::string& command, const std::string& data = {}, char separator = ' '); | ||||||
| 	void send_data(const game::netadr_s& address, const std::string& data); | 	void send_data(const game::netadr_t& address, const std::string& data); | ||||||
|  |  | ||||||
| 	bool are_addresses_equal(const game::netadr_s& a, const game::netadr_s& b); | 	bool are_addresses_equal(const game::netadr_t& a, const game::netadr_t& b); | ||||||
|  |  | ||||||
| 	const char* net_adr_to_string(const game::netadr_s& a); | 	const char* net_adr_to_string(const game::netadr_t& a); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline bool operator==(const game::netadr_s& a, const game::netadr_s& b) | inline bool operator==(const game::netadr_t& a, const game::netadr_t& b) | ||||||
| { | { | ||||||
| 	return network::are_addresses_equal(a, b); // | 	return network::are_addresses_equal(a, b); // | ||||||
| } | } | ||||||
|  |  | ||||||
| inline bool operator!=(const game::netadr_s& a, const game::netadr_s& b) | inline bool operator!=(const game::netadr_t& a, const game::netadr_t& b) | ||||||
| { | { | ||||||
| 	return !(a == b); // | 	return !(a == b); // | ||||||
| } | } | ||||||
| @@ -26,20 +26,20 @@ inline bool operator!=(const game::netadr_s& a, const game::netadr_s& b) | |||||||
| namespace std | namespace std | ||||||
| { | { | ||||||
| 	template <> | 	template <> | ||||||
| 	struct equal_to<game::netadr_s> | 	struct equal_to<game::netadr_t> | ||||||
| 	{ | 	{ | ||||||
| 		using result_type = bool; | 		using result_type = bool; | ||||||
|  |  | ||||||
| 		bool operator()(const game::netadr_s& lhs, const game::netadr_s& rhs) const | 		bool operator()(const game::netadr_t& lhs, const game::netadr_t& rhs) const | ||||||
| 		{ | 		{ | ||||||
| 			return network::are_addresses_equal(lhs, rhs); | 			return network::are_addresses_equal(lhs, rhs); | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	template <> | 	template <> | ||||||
| 	struct hash<game::netadr_s> | 	struct hash<game::netadr_t> | ||||||
| 	{ | 	{ | ||||||
| 		size_t operator()(const game::netadr_s& x) const noexcept | 		size_t operator()(const game::netadr_t& x) const noexcept | ||||||
| 		{ | 		{ | ||||||
| 			return hash<uint32_t>()(*reinterpret_cast<const uint32_t*>(&x.ip[0])) ^ hash<uint16_t>()(x.port); | 			return hash<uint32_t>()(*reinterpret_cast<const uint32_t*>(&x.ip[0])) ^ hash<uint16_t>()(x.port); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ namespace party | |||||||
| 	{ | 	{ | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			game::netadr_s host{}; | 			game::netadr_t host{}; | ||||||
| 			std::string challenge{}; | 			std::string challenge{}; | ||||||
| 			bool hostDefined{false}; | 			bool hostDefined{false}; | ||||||
| 		} connect_state; | 		} connect_state; | ||||||
| @@ -37,7 +37,7 @@ namespace party | |||||||
|  |  | ||||||
| 		int sv_maxclients; | 		int sv_maxclients; | ||||||
|  |  | ||||||
| 		void connect_to_party(const game::netadr_s& target, const std::string& mapname, const std::string& gametype) | 		void connect_to_party(const game::netadr_t& target, const std::string& mapname, const std::string& gametype) | ||||||
| 		{ | 		{ | ||||||
| 			if (game::environment::is_sp()) | 			if (game::environment::is_sp()) | ||||||
| 			{ | 			{ | ||||||
| @@ -58,7 +58,7 @@ namespace party | |||||||
|  |  | ||||||
| 			// CL_ConnectFromParty | 			// CL_ConnectFromParty | ||||||
| 			char session_info[0x100] = {}; | 			char session_info[0x100] = {}; | ||||||
| 			reinterpret_cast<void(*)(int, char*, const game::netadr_s*, const char*, const char*)>(0x1402C5700)( | 			reinterpret_cast<void(*)(int, char*, const game::netadr_t*, const char*, const char*)>(0x1402C5700)( | ||||||
| 				0, session_info, &target, mapname.data(), gametype.data()); | 				0, session_info, &target, mapname.data(), gametype.data()); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -146,7 +146,7 @@ namespace party | |||||||
| 		return count; | 		return count; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	game::netadr_s& get_target() | 	game::netadr_t& get_target() | ||||||
| 	{ | 	{ | ||||||
| 		return connect_state.host; | 		return connect_state.host; | ||||||
| 	} | 	} | ||||||
| @@ -175,7 +175,7 @@ namespace party | |||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void connect(const game::netadr_s& target) | 	void connect(const game::netadr_t& target) | ||||||
| 	{ | 	{ | ||||||
| 		if (game::environment::is_sp()) | 		if (game::environment::is_sp()) | ||||||
| 		{ | 		{ | ||||||
| @@ -252,7 +252,7 @@ namespace party | |||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				game::netadr_s target{}; | 				game::netadr_t target{}; | ||||||
| 				if (game::NET_StringToAdr(params[1], &target)) | 				if (game::NET_StringToAdr(params[1], &target)) | ||||||
| 				{ | 				{ | ||||||
| 					connect(target); | 					connect(target); | ||||||
| @@ -405,7 +405,7 @@ namespace party | |||||||
| 				console::info("%s\n", message.data()); | 				console::info("%s\n", message.data()); | ||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
| 			network::on("getInfo", [](const game::netadr_s& target, const std::string& data) | 			network::on("getInfo", [](const game::netadr_t& target, const std::string& data) | ||||||
| 			{ | 			{ | ||||||
| 				utils::info_string info; | 				utils::info_string info; | ||||||
| 				info.set("challenge", data); | 				info.set("challenge", data); | ||||||
| @@ -430,7 +430,7 @@ namespace party | |||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			network::on("infoResponse", [](const game::netadr_s& target, const std::string& data) | 			network::on("infoResponse", [](const game::netadr_t& target, const std::string& data) | ||||||
| 			{ | 			{ | ||||||
| 				const utils::info_string info(data); | 				const utils::info_string info(data); | ||||||
| 				server_list::handle_info_response(target, info); | 				server_list::handle_info_response(target, info); | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ namespace party | |||||||
|  |  | ||||||
| 	void reset_connect_state(); | 	void reset_connect_state(); | ||||||
|  |  | ||||||
| 	void connect(const game::netadr_s& target); | 	void connect(const game::netadr_t& target); | ||||||
| 	void map_restart(); | 	void map_restart(); | ||||||
|  |  | ||||||
| 	[[nodiscard]] int server_client_count(); | 	[[nodiscard]] int server_client_count(); | ||||||
| @@ -15,5 +15,5 @@ namespace party | |||||||
| 	[[nodiscard]] int get_client_count(); | 	[[nodiscard]] int get_client_count(); | ||||||
| 	[[nodiscard]] int get_bot_count(); | 	[[nodiscard]] int get_bot_count(); | ||||||
|  |  | ||||||
| 	[[nodiscard]] game::netadr_s& get_target(); | 	[[nodiscard]] game::netadr_t& get_target(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -150,7 +150,7 @@ namespace patches | |||||||
| 			return 0; | 			return 0; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		game::Font_s* get_chat_font_handle() | 		game::Font_t* get_chat_font_handle() | ||||||
| 		{ | 		{ | ||||||
| 			return game::R_RegisterFont("fonts/bigFont"); | 			return game::R_RegisterFont("fonts/bigFont"); | ||||||
| 		} | 		} | ||||||
| @@ -187,7 +187,7 @@ namespace patches | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		utils::hook::detour cmd_lui_notify_server_hook; | 		utils::hook::detour cmd_lui_notify_server_hook; | ||||||
| 		void cmd_lui_notify_server_stub(game::mp::gentity_s* ent) | 		void cmd_lui_notify_server_stub(game::mp::gentity_t* ent) | ||||||
| 		{ | 		{ | ||||||
| 			command::params_sv params{}; | 			command::params_sv params{}; | ||||||
| 			const auto menu_id = atoi(params.get(1)); | 			const auto menu_id = atoi(params.get(1)); | ||||||
|   | |||||||
| @@ -14,11 +14,11 @@ namespace rcon | |||||||
| 	namespace | 	namespace | ||||||
| 	{ | 	{ | ||||||
| 		bool is_redirecting_ = false; | 		bool is_redirecting_ = false; | ||||||
| 		game::netadr_s redirect_target_ = {}; | 		game::netadr_t redirect_target_ = {}; | ||||||
| 		std::string redirect_buffer = {}; | 		std::string redirect_buffer = {}; | ||||||
| 		std::recursive_mutex redirect_lock; | 		std::recursive_mutex redirect_lock; | ||||||
|  |  | ||||||
| 		void setup_redirect(const game::netadr_s& target) | 		void setup_redirect(const game::netadr_t& target) | ||||||
| 		{ | 		{ | ||||||
| 			std::lock_guard<std::recursive_mutex> $(redirect_lock); | 			std::lock_guard<std::recursive_mutex> $(redirect_lock); | ||||||
|  |  | ||||||
| @@ -92,7 +92,7 @@ namespace rcon | |||||||
|  |  | ||||||
| 			if (*reinterpret_cast<std::int32_t*>(0x1419E1AE0) >= 5) //clientUIActive.connectionState >= CA_CONNECTED | 			if (*reinterpret_cast<std::int32_t*>(0x1419E1AE0) >= 5) //clientUIActive.connectionState >= CA_CONNECTED | ||||||
| 			{ | 			{ | ||||||
| 				const auto target = *reinterpret_cast<game::netadr_s*>(0x141CB535C); | 				const auto target = *reinterpret_cast<game::netadr_t*>(0x141CB535C); | ||||||
| 				const auto buffer = password + " " + data; | 				const auto buffer = password + " " + data; | ||||||
| 				network::send(target, "rcon", buffer); | 				network::send(target, "rcon", buffer); | ||||||
| 			} | 			} | ||||||
| @@ -170,7 +170,7 @@ namespace rcon | |||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				network::on("rcon", [](const game::netadr_s& addr, const std::string& data) | 				network::on("rcon", [](const game::netadr_t& addr, const std::string& data) | ||||||
| 				{ | 				{ | ||||||
| 					const auto pos = data.find_first_of(" "); | 					const auto pos = data.find_first_of(" "); | ||||||
| 					if (pos == std::string::npos) | 					if (pos == std::string::npos) | ||||||
|   | |||||||
| @@ -33,14 +33,14 @@ namespace server_list | |||||||
| 			std::string map_name; | 			std::string map_name; | ||||||
| 			std::string game_type; | 			std::string game_type; | ||||||
| 			char in_game; | 			char in_game; | ||||||
| 			game::netadr_s address; | 			game::netadr_t address; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct | 		struct | ||||||
| 		{ | 		{ | ||||||
| 			game::netadr_s address{}; | 			game::netadr_t address{}; | ||||||
| 			volatile bool requesting = false; | 			volatile bool requesting = false; | ||||||
| 			std::unordered_map<game::netadr_s, int> queued_servers{}; | 			std::unordered_map<game::netadr_t, int> queued_servers{}; | ||||||
| 		} master_state; | 		} master_state; | ||||||
|  |  | ||||||
| 		volatile bool update_server_list = false; | 		volatile bool update_server_list = false; | ||||||
| @@ -307,12 +307,12 @@ namespace server_list | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	bool get_master_server(game::netadr_s& address) | 	bool get_master_server(game::netadr_t& address) | ||||||
| 	{ | 	{ | ||||||
| 		return game::NET_StringToAdr("server.alterware.dev:20810", &address); | 		return game::NET_StringToAdr("server.alterware.dev:20810", &address); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	void handle_info_response(const game::netadr_s& address, const utils::info_string& info) | 	void handle_info_response(const game::netadr_t& address, const utils::info_string& info) | ||||||
| 	{ | 	{ | ||||||
| 		int start_time{}; | 		int start_time{}; | ||||||
| 		const auto now = game::Sys_Milliseconds(); | 		const auto now = game::Sys_Milliseconds(); | ||||||
| @@ -436,7 +436,7 @@ namespace server_list | |||||||
|  |  | ||||||
| 			scheduler::loop(do_frame_work, scheduler::pipeline::main); | 			scheduler::loop(do_frame_work, scheduler::pipeline::main); | ||||||
|  |  | ||||||
| 			network::on("getServersResponse", [](const game::netadr_s& target, const std::string& data) | 			network::on("getServersResponse", [](const game::netadr_t& target, const std::string& data) | ||||||
| 			{ | 			{ | ||||||
| 				{ | 				{ | ||||||
| 					std::lock_guard<std::mutex> _(mutex); | 					std::lock_guard<std::mutex> _(mutex); | ||||||
| @@ -469,7 +469,7 @@ namespace server_list | |||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
| 						game::netadr_s address{}; | 						game::netadr_t address{}; | ||||||
| 						address.type = game::NA_IP; | 						address.type = game::NA_IP; | ||||||
| 						address.localNetID = game::NS_CLIENT1; | 						address.localNetID = game::NS_CLIENT1; | ||||||
| 						std::memcpy(&address.ip[0], data.data() + i + 0, 4); | 						std::memcpy(&address.ip[0], data.data() + i + 0, 4); | ||||||
|   | |||||||
| @@ -3,8 +3,8 @@ | |||||||
|  |  | ||||||
| namespace server_list | namespace server_list | ||||||
| { | { | ||||||
| 	bool get_master_server(game::netadr_s& address); | 	bool get_master_server(game::netadr_t& address); | ||||||
| 	void handle_info_response(const game::netadr_s& address, const utils::info_string& info); | 	void handle_info_response(const game::netadr_t& address, const utils::info_string& info); | ||||||
|  |  | ||||||
| 	bool sl_key_event(int key, int down); | 	bool sl_key_event(int key, int down); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -181,7 +181,7 @@ namespace game | |||||||
|  |  | ||||||
| 	static_assert(sizeof(db_internal_state) == 0x20); | 	static_assert(sizeof(db_internal_state) == 0x20); | ||||||
|  |  | ||||||
| 	struct db_z_stream_s | 	struct db_z_stream_t | ||||||
| 	{ | 	{ | ||||||
| 		unsigned char* next_in; | 		unsigned char* next_in; | ||||||
| 		unsigned int avail_in; | 		unsigned int avail_in; | ||||||
| @@ -216,7 +216,7 @@ namespace game | |||||||
| 		unsigned char* start_in; | 		unsigned char* start_in; | ||||||
| 		_OVERLAPPED overlapped; | 		_OVERLAPPED overlapped; | ||||||
| 		unsigned int readError; | 		unsigned int readError; | ||||||
| 		db_z_stream_s stream; | 		db_z_stream_t stream; | ||||||
| 		int readingResident; | 		int readingResident; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| @@ -1064,7 +1064,7 @@ namespace game | |||||||
| 		float t1; | 		float t1; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct Font_s | 	struct Font_t | ||||||
| 	{ | 	{ | ||||||
| 		const char* fontName; | 		const char* fontName; | ||||||
| 		int pixelHeight; | 		int pixelHeight; | ||||||
| @@ -1182,9 +1182,9 @@ namespace game | |||||||
| 		const char** argv[8]; | 		const char** argv[8]; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct cmd_function_s | 	struct cmd_function_t | ||||||
| 	{ | 	{ | ||||||
| 		cmd_function_s* next; | 		cmd_function_t* next; | ||||||
| 		const char* name; | 		const char* name; | ||||||
| 		void (__cdecl* function)(); | 		void (__cdecl* function)(); | ||||||
| 	}; | 	}; | ||||||
| @@ -1235,7 +1235,7 @@ namespace game | |||||||
| 		WEAPON_HAND_DEFAULT = 0x0, | 		WEAPON_HAND_DEFAULT = 0x0, | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct usercmd_s | 	struct usercmd_t | ||||||
| 	{ | 	{ | ||||||
| 		int serverTime; | 		int serverTime; | ||||||
| 		unsigned int buttons; | 		unsigned int buttons; | ||||||
| @@ -1311,7 +1311,7 @@ namespace game | |||||||
| 		bool hybridScope; | 		bool hybridScope; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct compressedAnimData_s | 	struct compressedAnimData_t | ||||||
| 	{ | 	{ | ||||||
| 		int flags; | 		int flags; | ||||||
| 		int animRate; | 		int animRate; | ||||||
| @@ -1330,7 +1330,7 @@ namespace game | |||||||
| 		int flags; | 		int flags; | ||||||
| 		int startTime; | 		int startTime; | ||||||
| 		float startPosition[3]; | 		float startPosition[3]; | ||||||
| 		compressedAnimData_s compressedAnimData; | 		compressedAnimData_t compressedAnimData; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct SlideState | 	struct SlideState | ||||||
| @@ -1339,7 +1339,7 @@ namespace game | |||||||
| 		int noFricTime; | 		int noFricTime; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct SprintState_s | 	struct SprintState_t | ||||||
| 	{ | 	{ | ||||||
| 		int sprintButtonUpRequired; | 		int sprintButtonUpRequired; | ||||||
| 		int sprintDelay; | 		int sprintDelay; | ||||||
| @@ -1398,7 +1398,7 @@ namespace game | |||||||
| 		NS_INVALID_NETSRC = 0x4, | 		NS_INVALID_NETSRC = 0x4, | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct netadr_s | 	struct netadr_t | ||||||
| 	{ | 	{ | ||||||
| 		netadrtype_t type; | 		netadrtype_t type; | ||||||
| 		unsigned char ip[4]; | 		unsigned char ip[4]; | ||||||
| @@ -1463,7 +1463,7 @@ namespace game | |||||||
| 		unsigned int rgba; | 		unsigned int rgba; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct hudelem_s | 	struct hudelem_t | ||||||
| 	{ | 	{ | ||||||
| 		he_type_t type; | 		he_type_t type; | ||||||
| 		float x; | 		float x; | ||||||
| @@ -1509,9 +1509,9 @@ namespace game | |||||||
| 		int flags; | 		int flags; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct game_hudelem_s | 	struct game_hudelem_t | ||||||
| 	{ | 	{ | ||||||
| 		hudelem_s elem; | 		hudelem_t elem; | ||||||
| 		int clientNum; | 		int clientNum; | ||||||
| 		int team; | 		int team; | ||||||
| 		int archived; | 		int archived; | ||||||
| @@ -1939,7 +1939,7 @@ namespace game | |||||||
| 		FxWorld *fxWorld; | 		FxWorld *fxWorld; | ||||||
| 		GfxWorld *gfxWorld; | 		GfxWorld *gfxWorld; | ||||||
| 		GfxLightDef *lightDef;*/ | 		GfxLightDef *lightDef;*/ | ||||||
| 		Font_s* font; | 		Font_t* font; | ||||||
| 		/*MenuList *menuList; | 		/*MenuList *menuList; | ||||||
| 		menuDef_t *menu; | 		menuDef_t *menu; | ||||||
| 		AnimationClass *animClass; | 		AnimationClass *animClass; | ||||||
| @@ -2018,21 +2018,21 @@ namespace game | |||||||
| 	namespace sp | 	namespace sp | ||||||
| 	{ | 	{ | ||||||
| 		// very shit structures for the moment cuz i cba mapping the whole thing out right now... | 		// very shit structures for the moment cuz i cba mapping the whole thing out right now... | ||||||
| 		struct gclient_s | 		struct gclient_t | ||||||
| 		{ | 		{ | ||||||
| 			char __0x00[0xB6DC]; | 			char __0x00[0xB6DC]; | ||||||
| 			int flags; | 			int flags; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct gentity_s | 		struct gentity_t | ||||||
| 		{ | 		{ | ||||||
| 			char __0x00[0x110]; | 			char __0x00[0x110]; | ||||||
| 			gclient_s* client; | 			gclient_t* client; | ||||||
| 			char __0x118[0x4C]; | 			char __0x118[0x4C]; | ||||||
| 			int flags; | 			int flags; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct playerState_s | 		struct playerState_t | ||||||
| 		{ | 		{ | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| @@ -2049,7 +2049,7 @@ namespace game | |||||||
| 	namespace mp | 	namespace mp | ||||||
| 	{ | 	{ | ||||||
| #pragma pack(push, 4) | #pragma pack(push, 4) | ||||||
| 		struct playerState_s | 		struct playerState_t | ||||||
| 		{ | 		{ | ||||||
| 			int commandTime; | 			int commandTime; | ||||||
| 			int pm_type; | 			int pm_type; | ||||||
| @@ -2101,7 +2101,7 @@ namespace game | |||||||
| 			vec3_t viewangles; | 			vec3_t viewangles; | ||||||
| 			char _0x190[0xAC]; | 			char _0x190[0xAC]; | ||||||
| 			int locationSelectionInfo; | 			int locationSelectionInfo; | ||||||
| 			SprintState_s sprintState; | 			SprintState_t sprintState; | ||||||
| 			float holdBreathScale; | 			float holdBreathScale; | ||||||
| 			int holdBreathTimer; | 			int holdBreathTimer; | ||||||
| 			float moveSpeedScaleMultiplier; | 			float moveSpeedScaleMultiplier; | ||||||
| @@ -2179,7 +2179,7 @@ namespace game | |||||||
| 			TEAM_NUM_TEAMS = 0x4, | 			TEAM_NUM_TEAMS = 0x4, | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct clientState_s | 		struct clientState_t | ||||||
| 		{ | 		{ | ||||||
| 			int clientIndex; | 			int clientIndex; | ||||||
| 			team_t team; | 			team_t team; | ||||||
| @@ -2203,21 +2203,21 @@ namespace game | |||||||
| 			int killCamEntity; | 			int killCamEntity; | ||||||
| 			int isInKillcam; | 			int isInKillcam; | ||||||
| 			char __0x332C[0x14]; | 			char __0x332C[0x14]; | ||||||
| 			usercmd_s cmd; | 			usercmd_t cmd; | ||||||
| 			usercmd_s oldcmd; | 			usercmd_t oldcmd; | ||||||
| 			int localClient; | 			int localClient; | ||||||
| 			char __0x33C4[0x24]; | 			char __0x33C4[0x24]; | ||||||
| 			float moveSpeedScaleMultiplier; | 			float moveSpeedScaleMultiplier; | ||||||
| 			int viewmodelIndex; | 			int viewmodelIndex; | ||||||
| 			int noSpectate; | 			int noSpectate; | ||||||
| 			clientState_s cs; | 			clientState_t cs; | ||||||
| 			ScoreInfo scores; | 			ScoreInfo scores; | ||||||
| 			char __pad[0x1B0]; | 			char __pad[0x1B0]; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct gclient_s | 		struct gclient_t | ||||||
| 		{ | 		{ | ||||||
| 			playerState_s ps; | 			playerState_t ps; | ||||||
| 			clientSession_t sess; | 			clientSession_t sess; | ||||||
| 			int flags; | 			int flags; | ||||||
| 			int spectatorClient; | 			int spectatorClient; | ||||||
| @@ -2266,11 +2266,11 @@ namespace game | |||||||
| 			char _0x14C[0xC]; | 			char _0x14C[0xC]; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct gentity_s | 		struct gentity_t | ||||||
| 		{ | 		{ | ||||||
| 			EntityState s; | 			EntityState s; | ||||||
| 			EntityShared r; | 			EntityShared r; | ||||||
| 			gclient_s* client; | 			gclient_t* client; | ||||||
| 			char _0x170[0x50]; | 			char _0x170[0x50]; | ||||||
| 			int flags; | 			int flags; | ||||||
| 			char _0x1C4[0x18]; | 			char _0x1C4[0x18]; | ||||||
| @@ -2279,7 +2279,7 @@ namespace game | |||||||
| 			char _0x1E4[0x10C]; | 			char _0x1E4[0x10C]; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct snapshot_s | 		struct snapshot_t | ||||||
| 		{ | 		{ | ||||||
| 			char _0x0[0x3C78]; | 			char _0x0[0x3C78]; | ||||||
| 			int ping; | 			int ping; | ||||||
| @@ -2288,12 +2288,12 @@ namespace game | |||||||
| 			int numClients; | 			int numClients; | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct cg_s | 		struct cg_t | ||||||
| 		{ | 		{ | ||||||
| 			playerState_s ps; | 			playerState_t ps; | ||||||
| 			char _0x3324[0x64]; | 			char _0x3324[0x64]; | ||||||
| 			snapshot_s* snap; | 			snapshot_t* snap; | ||||||
| 			snapshot_s* nextSnap; // theres alot after this cba rn | 			snapshot_t* nextSnap; // theres alot after this cba rn | ||||||
| 		}; | 		}; | ||||||
|  |  | ||||||
| 		struct netProfilePacket_t | 		struct netProfilePacket_t | ||||||
| @@ -2328,7 +2328,7 @@ namespace game | |||||||
| 			netsrc_t sock; | 			netsrc_t sock; | ||||||
| 			int dropped; | 			int dropped; | ||||||
| 			int incomingSequence; | 			int incomingSequence; | ||||||
| 			netadr_s remoteAddress; | 			netadr_t remoteAddress; | ||||||
| 			int fragmentSequence; | 			int fragmentSequence; | ||||||
| 			int fragmentLength; | 			int fragmentLength; | ||||||
| 			char* fragmentBuffer; | 			char* fragmentBuffer; | ||||||
| @@ -2378,7 +2378,7 @@ namespace game | |||||||
| 			int reliableSent; | 			int reliableSent; | ||||||
| 			int messageAcknowledge; | 			int messageAcknowledge; | ||||||
| 			char _0xC30[0x41238]; | 			char _0xC30[0x41238]; | ||||||
| 			gentity_s* gentity; | 			gentity_t* gentity; | ||||||
| 			char name[16]; | 			char name[16]; | ||||||
| 			int lastPacketTime; | 			int lastPacketTime; | ||||||
| 			int lastConnectTime; | 			int lastConnectTime; | ||||||
| @@ -2411,7 +2411,7 @@ namespace game | |||||||
|  |  | ||||||
| 		struct missileFireParms | 		struct missileFireParms | ||||||
| 		{ | 		{ | ||||||
| 			gentity_s* target; | 			gentity_t* target; | ||||||
| 			float targetPosOrOffset[3]; | 			float targetPosOrOffset[3]; | ||||||
| 			float autoDetonateTime; | 			float autoDetonateTime; | ||||||
| 			bool lockon; | 			bool lockon; | ||||||
| @@ -2423,10 +2423,10 @@ namespace game | |||||||
|  |  | ||||||
| 	static_assert(sizeof(mp::client_t) == 0x83570); | 	static_assert(sizeof(mp::client_t) == 0x83570); | ||||||
|  |  | ||||||
| 	union playerState_s | 	union playerState_t | ||||||
| 	{ | 	{ | ||||||
| 		sp::playerState_s* sp; | 		sp::playerState_t* sp; | ||||||
| 		mp::playerState_s* mp; | 		mp::playerState_t* mp; | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	enum GfxDrawSceneMethod | 	enum GfxDrawSceneMethod | ||||||
| @@ -2457,7 +2457,7 @@ namespace game | |||||||
| 		TECHNIQUE_NONE = 0x137, | 		TECHNIQUE_NONE = 0x137, | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	struct GfxDrawMethod_s | 	struct GfxDrawMethod_t | ||||||
| 	{ | 	{ | ||||||
| 		int drawScene; | 		int drawScene; | ||||||
| 		int baseTechType; | 		int baseTechType; | ||||||
| @@ -2509,8 +2509,8 @@ namespace game | |||||||
| 	struct pmove_t | 	struct pmove_t | ||||||
| 	{ | 	{ | ||||||
| 		void* ps; | 		void* ps; | ||||||
| 		usercmd_s cmd; | 		usercmd_t cmd; | ||||||
| 		usercmd_s oldcmd; | 		usercmd_t oldcmd; | ||||||
| 		int tracemask; | 		int tracemask; | ||||||
| 		int numtouch; | 		int numtouch; | ||||||
| 		int touchents[32]; | 		int touchents[32]; | ||||||
|   | |||||||
| @@ -39,9 +39,9 @@ namespace game | |||||||
| 	WEAK symbol<bool()> CL_IsCgameInitialized{0x140234DA0, 0x1402B9A70}; | 	WEAK symbol<bool()> CL_IsCgameInitialized{0x140234DA0, 0x1402B9A70}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x1401F2E20, 0x140271320}; | 	WEAK symbol<void(int localClientNum, const char* message)> CG_GameMessage{0x1401F2E20, 0x140271320}; | ||||||
| 	WEAK symbol<void(int localClientNum, mp::cg_s* cg, const char* dvar, const char* value)> CG_SetClientDvarFromServer{0x0, 0x14028A2C0}; | 	WEAK symbol<void(int localClientNum, mp::cg_t* cg, const char* dvar, const char* value)> CG_SetClientDvarFromServer{0x0, 0x14028A2C0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void(const char* cmdName, void (), cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{0x1403B3570, 0x1403F7070}; | 	WEAK symbol<void(const char* cmdName, void (), cmd_function_t* allocedCmd)> Cmd_AddCommandInternal{0x1403B3570, 0x1403F7070}; | ||||||
| 	WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x1403B3B10, 0x1403F7680}; | 	WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x1403B3B10, 0x1403F7680}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void (XAssetType type, void (__cdecl *func)(XAssetHeader, void*), void* inData, bool includeOverride)> DB_EnumXAssets_FastFile{0x140271F50, 0x14031EF90}; | 	WEAK symbol<void (XAssetType type, void (__cdecl *func)(XAssetHeader, void*), void* inData, bool includeOverride)> DB_EnumXAssets_FastFile{0x140271F50, 0x14031EF90}; | ||||||
| @@ -94,17 +94,17 @@ namespace game | |||||||
| 	WEAK symbol<void(const char *path, const char *dir)> FS_AddLocalizedGameDirectory{0x14041A2F0, 0x1404DC760}; | 	WEAK symbol<void(const char *path, const char *dir)> FS_AddLocalizedGameDirectory{0x14041A2F0, 0x1404DC760}; | ||||||
|  |  | ||||||
| 	WEAK symbol<Weapon(const char* pickupName, int model)> G_FindItem{0x140462490, 0x14021B7E0}; | 	WEAK symbol<Weapon(const char* pickupName, int model)> G_FindItem{0x140462490, 0x14021B7E0}; | ||||||
| 	WEAK symbol<int(playerState_s* ps, Weapon weapon, int dualWield, int startInAltMode, int usedBefore)> G_GivePlayerWeapon{0x140359E20, 0x1403DA5E0}; | 	WEAK symbol<int(playerState_t* ps, Weapon weapon, int dualWield, int startInAltMode, int usedBefore)> G_GivePlayerWeapon{0x140359E20, 0x1403DA5E0}; | ||||||
| 	WEAK symbol<Weapon(const char* name)> G_GetWeaponForName{0x140359890, 0x1403DA060}; | 	WEAK symbol<Weapon(const char* name)> G_GetWeaponForName{0x140359890, 0x1403DA060}; | ||||||
| 	WEAK symbol<void()> G_Glass_Update{0x14030E680, 0x140397450}; | 	WEAK symbol<void()> G_Glass_Update{0x14030E680, 0x140397450}; | ||||||
| 	WEAK symbol<void (playerState_s* ps, Weapon weapon, int hadWeapon)> G_InitializeAmmo{0x140311F00, 0x14039AEA0}; | 	WEAK symbol<void (playerState_t* ps, Weapon weapon, int hadWeapon)> G_InitializeAmmo{0x140311F00, 0x14039AEA0}; | ||||||
| 	WEAK symbol<void(int clientNum, Weapon weapon)> G_SelectWeapon{0x14035A200, 0x1403DA880}; | 	WEAK symbol<void(int clientNum, Weapon weapon)> G_SelectWeapon{0x14035A200, 0x1403DA880}; | ||||||
| 	WEAK symbol<int(playerState_s* ps, Weapon weapon)> G_TakePlayerWeapon{0x14035A350, 0x1403DA9C0}; | 	WEAK symbol<int(playerState_t* ps, Weapon weapon)> G_TakePlayerWeapon{0x14035A350, 0x1403DA9C0}; | ||||||
| 	WEAK symbol<unsigned int (const char* name, /*ConfigString*/ unsigned int start, unsigned int max, int create, | 	WEAK symbol<unsigned int (const char* name, /*ConfigString*/ unsigned int start, unsigned int max, int create, | ||||||
| 	                          const char* errormsg)> G_FindConfigstringIndex{0x0, 0x140161F90}; | 	                          const char* errormsg)> G_FindConfigstringIndex{0x0, 0x140161F90}; | ||||||
| 	WEAK symbol<int(int server_time)> G_RunFrame{0x0, 0x1403A05E0}; | 	WEAK symbol<int(int server_time)> G_RunFrame{0x0, 0x1403A05E0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<game_hudelem_s*(int clientNum, int teamNum)> HudElem_Alloc{0x0, 0x1403997E0}; | 	WEAK symbol<game_hudelem_t*(int clientNum, int teamNum)> HudElem_Alloc{0x0, 0x1403997E0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<char*(char* string)> I_CleanStr{0x140432460, 0x1404F63C0}; | 	WEAK symbol<char*(char* string)> I_CleanStr{0x140432460, 0x1404F63C0}; | ||||||
|  |  | ||||||
| @@ -144,18 +144,18 @@ namespace game | |||||||
|  |  | ||||||
| 	WEAK symbol<Material*(const char* material)> Material_RegisterHandle{0x140523D90, 0x1405F0E20}; | 	WEAK symbol<Material*(const char* material)> Material_RegisterHandle{0x140523D90, 0x1405F0E20}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void(netsrc_t, netadr_s*, const char*)> NET_OutOfBandPrint{0, 0x14041D5C0}; | 	WEAK symbol<void(netsrc_t, netadr_t*, const char*)> NET_OutOfBandPrint{0, 0x14041D5C0}; | ||||||
| 	WEAK symbol<void(netsrc_t sock, int length, const void* data, const netadr_s* to)> NET_SendLoopPacket{0, 0x14041D780}; | 	WEAK symbol<void(netsrc_t sock, int length, const void* data, const netadr_t* to)> NET_SendLoopPacket{0, 0x14041D780}; | ||||||
| 	WEAK symbol<bool(const char* s, netadr_s* a)> NET_StringToAdr{0, 0x14041D870}; | 	WEAK symbol<bool(const char* s, netadr_t* a)> NET_StringToAdr{0, 0x14041D870}; | ||||||
| 	WEAK symbol<void(netadr_s*, sockaddr*)> NetadrToSockadr{0, 0x1404E53D0}; | 	WEAK symbol<void(netadr_t*, sockaddr*)> NetadrToSockadr{0, 0x1404E53D0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void(float x, float y, float width, float height, float s0, float t0, float s1, float t1, | 	WEAK symbol<void(float x, float y, float width, float height, float s0, float t0, float s1, float t1, | ||||||
| 	                  float* color, Material* material)> R_AddCmdDrawStretchPic{0x140234460, 0x140600BE0}; | 	                  float* color, Material* material)> R_AddCmdDrawStretchPic{0x140234460, 0x140600BE0}; | ||||||
| 	WEAK symbol<void(const char*, int, Font_s*, float, float, float, float, float, float*, int)> R_AddCmdDrawText{0x140533E40, 0x140601070}; | 	WEAK symbol<void(const char*, int, Font_t*, float, float, float, float, float, float*, int)> R_AddCmdDrawText{0x140533E40, 0x140601070}; | ||||||
| 	WEAK symbol<void(const char*, int, Font_s*, float, float, float, float, float, const float*, int, int, char)> R_AddCmdDrawTextWithCursor{0x140534170, 0x1406013A0}; | 	WEAK symbol<void(const char*, int, Font_t*, float, float, float, float, float, const float*, int, int, char)> R_AddCmdDrawTextWithCursor{0x140534170, 0x1406013A0}; | ||||||
| 	WEAK symbol<Font_s*(const char* font)> R_RegisterFont{0x1405130B0, 0x1405DFAC0}; | 	WEAK symbol<Font_t*(const char* font)> R_RegisterFont{0x1405130B0, 0x1405DFAC0}; | ||||||
| 	WEAK symbol<void()> R_SyncRenderThread{0x140535AF0, 0x140602D30}; | 	WEAK symbol<void()> R_SyncRenderThread{0x140535AF0, 0x140602D30}; | ||||||
| 	WEAK symbol<int(const char* text, int maxChars, Font_s* font)> R_TextWidth{0x140513390, 0x1405DFDB0}; | 	WEAK symbol<int(const char* text, int maxChars, Font_t* font)> R_TextWidth{0x140513390, 0x1405DFDB0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<ScreenPlacement*()> ScrPlace_GetViewPlacement{0x14024D150, 0x1402F6D40}; | 	WEAK symbol<ScreenPlacement*()> ScrPlace_GetViewPlacement{0x14024D150, 0x1402F6D40}; | ||||||
|  |  | ||||||
| @@ -203,20 +203,20 @@ namespace game | |||||||
| 	WEAK symbol<void()> SV_Cmd_EndTokenizedString{0, 0x1403F8110}; | 	WEAK symbol<void()> SV_Cmd_EndTokenizedString{0, 0x1403F8110}; | ||||||
| 	WEAK symbol<void()> SV_MatchEnd{0x0, 0x14047A090}; | 	WEAK symbol<void()> SV_MatchEnd{0x0, 0x14047A090}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void(netadr_s* from)> SV_DirectConnect{0, 0x140471390}; | 	WEAK symbol<void(netadr_t* from)> SV_DirectConnect{0, 0x140471390}; | ||||||
| 	WEAK symbol<void(int, int, const char*)> SV_GameSendServerCommand{0x140490F40, 0x1404758C0}; | 	WEAK symbol<void(int, int, const char*)> SV_GameSendServerCommand{0x140490F40, 0x1404758C0}; | ||||||
| 	WEAK symbol<bool()> SV_Loaded{0x140491820, 0x1404770C0}; | 	WEAK symbol<bool()> SV_Loaded{0x140491820, 0x1404770C0}; | ||||||
| 	WEAK symbol<void(int localClientNum, const char* map, bool mapIsPreloaded)> SV_StartMap{0, 0x140470170}; | 	WEAK symbol<void(int localClientNum, const char* map, bool mapIsPreloaded)> SV_StartMap{0, 0x140470170}; | ||||||
| 	WEAK symbol<void(int localClientNum, const char* map, bool mapIsPreloaded, bool migrate)> SV_StartMapForParty{0, 0x1404702F0}; | 	WEAK symbol<void(int localClientNum, const char* map, bool mapIsPreloaded, bool migrate)> SV_StartMapForParty{0, 0x1404702F0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<mp::gentity_s*(const char*, unsigned int, unsigned int, unsigned int)> SV_AddBot{0, 0x140470920}; | 	WEAK symbol<mp::gentity_t*(const char*, unsigned int, unsigned int, unsigned int)> SV_AddBot{0, 0x140470920}; | ||||||
| 	WEAK symbol<bool(int clientNum)> SV_BotIsBot{0, 0x140461340}; | 	WEAK symbol<bool(int clientNum)> SV_BotIsBot{0, 0x140461340}; | ||||||
| 	WEAK symbol<const char*()> SV_BotGetRandomName{0, 0x140460B80}; | 	WEAK symbol<const char*()> SV_BotGetRandomName{0, 0x140460B80}; | ||||||
| 	WEAK symbol<void(mp::gentity_s*)> SV_SpawnTestClient{0, 0x1404740A0}; | 	WEAK symbol<void(mp::gentity_t*)> SV_SpawnTestClient{0, 0x1404740A0}; | ||||||
|  |  | ||||||
| 	WEAK symbol<void(mp::client_t*, const char*, int)> SV_ExecuteClientCommand{0, 0x140472430}; | 	WEAK symbol<void(mp::client_t*, const char*, int)> SV_ExecuteClientCommand{0, 0x140472430}; | ||||||
| 	WEAK symbol<void()> SV_FastRestart{0x14048B890, 0x14046F440}; | 	WEAK symbol<void()> SV_FastRestart{0x14048B890, 0x14046F440}; | ||||||
| 	WEAK symbol<playerState_s*(int num)> SV_GetPlayerstateForClientNum{0x140490F80, 0x140475A10}; | 	WEAK symbol<playerState_t*(int num)> SV_GetPlayerstateForClientNum{0x140490F80, 0x140475A10}; | ||||||
| 	WEAK symbol<const char*(int clientNum)> SV_GetGuid{0, 0x140475990}; | 	WEAK symbol<const char*(int clientNum)> SV_GetGuid{0, 0x140475990}; | ||||||
| 	WEAK symbol<void(int clientNum, const char* reason)> SV_KickClientNum{0, 0x14046F730}; | 	WEAK symbol<void(int clientNum, const char* reason)> SV_KickClientNum{0, 0x14046F730}; | ||||||
| 	WEAK symbol<void(int index, const char* string)> SV_SetConfigstring{0, 0x140477450}; | 	WEAK symbol<void(int index, const char* string)> SV_SetConfigstring{0, 0x140477450}; | ||||||
| @@ -225,7 +225,7 @@ namespace game | |||||||
| 	WEAK symbol<bool()> Sys_IsDatabaseReady2{0x1403C2D40, 0x140423920}; | 	WEAK symbol<bool()> Sys_IsDatabaseReady2{0x1403C2D40, 0x140423920}; | ||||||
| 	WEAK symbol<int()> Sys_Milliseconds{0x14043D2A0, 0x140501CA0}; | 	WEAK symbol<int()> Sys_Milliseconds{0x14043D2A0, 0x140501CA0}; | ||||||
| 	WEAK symbol<void()> Sys_ShowConsole{0x14043E650, 0x140503130}; | 	WEAK symbol<void()> Sys_ShowConsole{0x14043E650, 0x140503130}; | ||||||
| 	WEAK symbol<bool(int, void const*, const netadr_s*)> Sys_SendPacket{0x14043D000, 0x140501A00}; | 	WEAK symbol<bool(int, void const*, const netadr_t*)> Sys_SendPacket{0x14043D000, 0x140501A00}; | ||||||
| 	WEAK symbol<void*(int valueIndex)> Sys_GetValue{0x1403C2C30, 0x1404237D0}; | 	WEAK symbol<void*(int valueIndex)> Sys_GetValue{0x1403C2C30, 0x1404237D0}; | ||||||
| 	WEAK symbol<bool()> Sys_IsMainThread{0x1478FC470, 0x140423950}; | 	WEAK symbol<bool()> Sys_IsMainThread{0x1478FC470, 0x140423950}; | ||||||
| 	WEAK symbol<HANDLE(Sys_Folder folder, const char* baseFilename)> Sys_CreateFile{0x140434B10, 0x1404F8FD0}; | 	WEAK symbol<HANDLE(Sys_Folder folder, const char* baseFilename)> Sys_CreateFile{0x140434B10, 0x1404F8FD0}; | ||||||
| @@ -257,7 +257,7 @@ namespace game | |||||||
|  |  | ||||||
| 	WEAK symbol<CmdArgs> cmd_args{0x144CE7F70, 0x144518480}; | 	WEAK symbol<CmdArgs> cmd_args{0x144CE7F70, 0x144518480}; | ||||||
| 	WEAK symbol<CmdArgs> sv_cmd_args{0x144CE8020, 0x144518530}; | 	WEAK symbol<CmdArgs> sv_cmd_args{0x144CE8020, 0x144518530}; | ||||||
| 	WEAK symbol<cmd_function_s*> cmd_functions{0x144CE80C8, 0x1445185D8}; | 	WEAK symbol<cmd_function_t*> cmd_functions{0x144CE80C8, 0x1445185D8}; | ||||||
|  |  | ||||||
| 	WEAK symbol<int> dvarCount{0x1458CBA3C, 0x1478EADF4}; | 	WEAK symbol<int> dvarCount{0x1458CBA3C, 0x1478EADF4}; | ||||||
| 	WEAK symbol<dvar_t*> sortedDvars{0x1458CBA60, 0x1478EAE10}; | 	WEAK symbol<dvar_t*> sortedDvars{0x1458CBA60, 0x1478EAE10}; | ||||||
| @@ -300,20 +300,20 @@ namespace game | |||||||
|  |  | ||||||
| 	WEAK symbol<DWORD> threadIds{0x144DE6640, 0x1446B4960}; | 	WEAK symbol<DWORD> threadIds{0x144DE6640, 0x1446B4960}; | ||||||
|  |  | ||||||
| 	WEAK symbol<GfxDrawMethod_s> gfxDrawMethod{0x145F525A8, 0x1480350D8}; | 	WEAK symbol<GfxDrawMethod_t> gfxDrawMethod{0x145F525A8, 0x1480350D8}; | ||||||
|  |  | ||||||
| 	namespace sp | 	namespace sp | ||||||
| 	{ | 	{ | ||||||
| 		WEAK symbol<gentity_s> g_entities{0x143C91600, 0}; | 		WEAK symbol<gentity_t> g_entities{0x143C91600, 0}; | ||||||
|  |  | ||||||
| 		WEAK symbol<XZone> g_zones_0{0x1434892D8, 0}; | 		WEAK symbol<XZone> g_zones_0{0x1434892D8, 0}; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	namespace mp | 	namespace mp | ||||||
| 	{ | 	{ | ||||||
| 		WEAK symbol<cg_s> cgArray{0, 0x14176EC00}; | 		WEAK symbol<cg_t> cgArray{0, 0x14176EC00}; | ||||||
|  |  | ||||||
| 		WEAK symbol<gentity_s> g_entities{0, 0x14427A0E0}; | 		WEAK symbol<gentity_t> g_entities{0, 0x14427A0E0}; | ||||||
|  |  | ||||||
| 		WEAK symbol<int> svs_clientCount{0, 0x14647B28C}; | 		WEAK symbol<int> svs_clientCount{0, 0x14647B28C}; | ||||||
| 		WEAK symbol<client_t> svs_clients{0, 0x14647B290}; | 		WEAK symbol<client_t> svs_clients{0, 0x14647B290}; | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								src/common/utils/command_line.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/common/utils/command_line.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | |||||||
|  | #include "command_line.hpp" | ||||||
|  | #include "nt.hpp" | ||||||
|  |  | ||||||
|  | #include <shellapi.h> | ||||||
|  | #include <winrt/Windows.Foundation.h> | ||||||
|  |  | ||||||
|  | namespace utils::command_line | ||||||
|  | { | ||||||
|  | 	template <typename type, typename deleter> | ||||||
|  | 	constexpr std::unique_ptr<type, deleter> make_unique_ptr(type* ptr, deleter&& del) | ||||||
|  | 	{ | ||||||
|  | 		return std::unique_ptr<type, deleter&&>(ptr, std::forward<deleter>(del)); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	const std::vector<std::filesystem::path>& get_args() | ||||||
|  | 	{ | ||||||
|  | 		static const auto args = []() | ||||||
|  | 		{ | ||||||
|  | 			auto argc = 0; | ||||||
|  | 			const auto cmd_line = winrt::check_pointer(::GetCommandLineW()); | ||||||
|  | 			const auto up = make_unique_ptr(winrt::check_pointer(::CommandLineToArgvW(cmd_line, &argc)), ::LocalFree); | ||||||
|  | 			const auto argv = up.get(); | ||||||
|  |  | ||||||
|  | 			std::vector<std::filesystem::path> vec(argc); | ||||||
|  | 			std::transform(argv, argv + argc, vec.begin(), [](const auto* path) | ||||||
|  | 			{ | ||||||
|  | 				return std::filesystem::path(path); | ||||||
|  | 			}); | ||||||
|  |  | ||||||
|  | 			return vec; | ||||||
|  | 		}(); | ||||||
|  |  | ||||||
|  | 		return args; | ||||||
|  | 	} | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								src/common/utils/command_line.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/common/utils/command_line.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | #pragma once | ||||||
|  |  | ||||||
|  | #include <filesystem> | ||||||
|  | #include <vector> | ||||||
|  |  | ||||||
|  | namespace utils::command_line | ||||||
|  | { | ||||||
|  | 	[[nodiscard]] const std::vector<std::filesystem::path>& get_args(); | ||||||
|  | } | ||||||
| @@ -109,6 +109,86 @@ namespace utils::compression | |||||||
| 			result.resize(length); | 			result.resize(length); | ||||||
| 			return result; | 			return result; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		std::vector<std::uint8_t> decompress(std::span<const std::uint8_t> input, std::size_t exp_output_size, double growth_rate) | ||||||
|  | 		{ | ||||||
|  | 			auto decompress_internal = [](std::uint8_t* output, uLong* output_size, const std::uint8_t* input, uLong* input_size) | ||||||
|  | 			{ | ||||||
|  | 				return uncompress2( | ||||||
|  | 					reinterpret_cast<Bytef*>(output), output_size, | ||||||
|  | 					reinterpret_cast<const Bytef*>(input), input_size | ||||||
|  | 				); | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			auto output_size = static_cast<uLong>(std::max(exp_output_size, std::size_t(256))); | ||||||
|  | 			std::vector<std::uint8_t> output(output_size); | ||||||
|  |  | ||||||
|  | 			auto input_size = static_cast<uLong>(input.size()); | ||||||
|  | 			auto status = decompress_internal(output.data(), &output_size, input.data(), &input_size); | ||||||
|  |  | ||||||
|  | 			if (status == Z_BUF_ERROR) | ||||||
|  | 			{ | ||||||
|  | 				const auto decompression_ratio = (input_size / static_cast<double>(output.size())) - 0.04; | ||||||
|  | 				output_size = static_cast<uLong>(std::max(input.size() / decompression_ratio, static_cast<double>(output_size))); | ||||||
|  | 				output.resize(output_size); | ||||||
|  |  | ||||||
|  | 				input_size = static_cast<uLong>(input.size()); | ||||||
|  | 				status = decompress_internal(output.data(), &output_size, input.data(), &input_size); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			for (growth_rate = std::max(growth_rate, 1.0); status == Z_BUF_ERROR;) | ||||||
|  | 			{ | ||||||
|  | 				output_size = 4 + static_cast<uLong>(growth_rate * output.size()); | ||||||
|  | 				output.resize(output_size); | ||||||
|  |  | ||||||
|  | 				input_size = static_cast<uLong>(input.size()); | ||||||
|  | 				status = decompress_internal(output.data(), &output_size, input.data(), &input_size); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if (status != Z_OK) | ||||||
|  | 			{ | ||||||
|  | 				output.clear(); | ||||||
|  | 				return output; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			output.resize(output_size); | ||||||
|  | 			return output; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		std::vector<std::uint8_t> compress(std::span<const std::uint8_t> input, std::size_t exp_output_size, double growth_rate) | ||||||
|  | 		{ | ||||||
|  | 			auto compress_internal = [](std::uint8_t* output, uLong* output_size, const std::uint8_t* input, uLong input_size) | ||||||
|  | 			{ | ||||||
|  | 				return compress2( | ||||||
|  | 					reinterpret_cast<Bytef*>(output), output_size, | ||||||
|  | 					reinterpret_cast<const Bytef*>(input), input_size, | ||||||
|  | 					Z_BEST_COMPRESSION | ||||||
|  | 				); | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			auto output_size = static_cast<uLong>(std::max(exp_output_size, std::size_t(256))); | ||||||
|  | 			std::vector<std::uint8_t> output(output_size); | ||||||
|  |  | ||||||
|  | 			const auto input_size = static_cast<uLong>(input.size()); | ||||||
|  | 			auto status = compress_internal(output.data(), &output_size, input.data(), input_size); | ||||||
|  |  | ||||||
|  | 			for (growth_rate = std::max(growth_rate, 1.0); status == Z_BUF_ERROR;) | ||||||
|  | 			{ | ||||||
|  | 				output_size = 4 + static_cast<uLong>(growth_rate * output.size()); | ||||||
|  | 				output.resize(output_size); | ||||||
|  |  | ||||||
|  | 				status = compress_internal(output.data(), &output_size, input.data(), input_size); | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if (status != Z_OK) | ||||||
|  | 			{ | ||||||
|  | 				output.clear(); | ||||||
|  | 				return output; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			output.resize(output_size); | ||||||
|  | 			return output; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	namespace zip | 	namespace zip | ||||||
|   | |||||||
| @@ -1,7 +1,9 @@ | |||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
|  | #include <span> | ||||||
| #include <string> | #include <string> | ||||||
| #include <unordered_map> | #include <unordered_map> | ||||||
|  | #include <vector> | ||||||
|  |  | ||||||
| #define CHUNK 16384u | #define CHUNK 16384u | ||||||
|  |  | ||||||
| @@ -11,6 +13,9 @@ namespace utils::compression | |||||||
| 	{ | 	{ | ||||||
| 		std::string compress(const std::string& data); | 		std::string compress(const std::string& data); | ||||||
| 		std::string decompress(const std::string& data); | 		std::string decompress(const std::string& data); | ||||||
|  |  | ||||||
|  | 		std::vector<std::uint8_t> compress(std::span<const std::uint8_t> input, std::size_t exp_output_size, double growth_rate = 2.0); | ||||||
|  | 		std::vector<std::uint8_t> decompress(std::span<const std::uint8_t> input, std::size_t exp_output_size, double growth_rate = 2.0); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	namespace zip | 	namespace zip | ||||||
|   | |||||||
| @@ -115,13 +115,13 @@ namespace utils::string | |||||||
|  |  | ||||||
| 	void strip(const char* in, char* out, size_t max) | 	void strip(const char* in, char* out, size_t max) | ||||||
| 	{ | 	{ | ||||||
| 		if (!in || !out) return; | 		if (!in || !out || !max) return; | ||||||
|  |  | ||||||
| 		max--; | 		max--; | ||||||
| 		auto current = 0u; | 		auto current = 0u; | ||||||
| 		while (*in != 0 && current < max) | 		while (*in != 0 && current < max) | ||||||
| 		{ | 		{ | ||||||
| 			const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48); | 			const auto color_index = (static_cast<size_t>(*(in + 1) - 48)) >= 0xC ? 7 : (*(in + 1) - 48); | ||||||
|  |  | ||||||
| 			if (*in == '^' && (color_index != 7 || *(in + 1) == '7')) | 			if (*in == '^' && (color_index != 7 || *(in + 1) == '7')) | ||||||
| 			{ | 			{ | ||||||
| @@ -140,6 +140,32 @@ namespace utils::string | |||||||
| 		*out = '\0'; | 		*out = '\0'; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	std::string strip(std::string_view sv, bool strip_default_color) | ||||||
|  | 	{ | ||||||
|  | 		std::string in(sv); | ||||||
|  |  | ||||||
|  | 		for (std::size_t i = 0; i + 1 < in.size();) | ||||||
|  | 		{ | ||||||
|  | 			if (in[i] == '^' && static_cast<std::size_t>(in[i + 1] - '0') < 0xC) | ||||||
|  | 			{ | ||||||
|  | 				if (in[i + 1] != '7' || strip_default_color) | ||||||
|  | 				{ | ||||||
|  | 					in.erase(in.begin() + i, in.begin() + i + 2); | ||||||
|  | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
|  | 					i += 2; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				i += 1; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		return in; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	std::string convert(const std::wstring& wstr) | 	std::string convert(const std::wstring& wstr) | ||||||
| 	{ | 	{ | ||||||
| 		std::string result; | 		std::string result; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "memory.hpp" | #include "memory.hpp" | ||||||
| #include <cstdint> | #include <cstdint> | ||||||
|  | #include <span> | ||||||
|  |  | ||||||
| template <class Type, size_t n> | template <class Type, size_t n> | ||||||
| constexpr auto ARRAY_COUNT(Type(&)[n]) { return n; } | constexpr auto ARRAY_COUNT(Type(&)[n]) { return n; } | ||||||
| @@ -91,6 +92,7 @@ namespace utils::string | |||||||
| 	std::string get_clipboard_data(); | 	std::string get_clipboard_data(); | ||||||
|  |  | ||||||
| 	void strip(const char* in, char* out, size_t max); | 	void strip(const char* in, char* out, size_t max); | ||||||
|  | 	std::string strip(std::string_view sv, bool strip_default_color = false); | ||||||
|  |  | ||||||
| 	std::string convert(const std::wstring& wstr); | 	std::string convert(const std::wstring& wstr); | ||||||
| 	std::wstring convert(const std::string& str); | 	std::wstring convert(const std::string& str); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user