Stuff Learned From Legacy

This commit is contained in:
TheBrokenRail 2021-11-30 21:54:43 -05:00
parent 55679dd54c
commit 406aa3f9a6
5 changed files with 13 additions and 10 deletions

View File

@ -83,9 +83,11 @@ void init_creative() {
patch((void *) 0x8d090, nop_patch); patch((void *) 0x8d090, nop_patch);
patch((void *) 0x91d48, nop_patch); patch((void *) 0x91d48, nop_patch);
patch((void *) 0x92098, nop_patch); patch((void *) 0x92098, nop_patch);
unsigned char FillingContainer_removeResource_creative_check_patch[4] = {0x03, 0x00, 0x53, 0xe1}; // "cmp r3, r3" unsigned char inv_creative_check_r3_patch[4] = {0x03, 0x00, 0x53, 0xe1}; // "cmp r3, r3"
patch((void *) 0x923c0, FillingContainer_removeResource_creative_check_patch); patch((void *) 0x923c0, inv_creative_check_r3_patch);
patch((void *) 0x92828, nop_patch); patch((void *) 0x92828, nop_patch);
unsigned char inv_creative_check_r1_patch[4] = {0x01, 0x00, 0x51, 0xe1}; // "cmp r1, r1"
patch((void *) 0x9282c, inv_creative_check_r1_patch);
// Display Slot Count // Display Slot Count
patch((void *) 0x1e3f4, nop_patch); patch((void *) 0x1e3f4, nop_patch);
unsigned char slot_count_patch[4] = {0x18, 0x00, 0x00, 0xea}; // "b 0x27110" unsigned char slot_count_patch[4] = {0x18, 0x00, 0x00, 0xea}; // "b 0x27110"

View File

@ -9,11 +9,11 @@
// Death Messages // Death Messages
static std::string get_death_message(unsigned char *player) { static std::string get_death_message(unsigned char *player) {
// Get Username // Get Username
char *username = *(char **) (player + Player_username_property_offset); std::string *username = (std::string *) (player + Player_username_property_offset);
// Prepare Death Message // Prepare Death Message
std::string message; std::string message;
message.append(username); message.append(username->c_str());
message.append(" has died"); message.append(" has died");
// Return // Return

View File

@ -50,6 +50,7 @@ static void _handle_drop(unsigned char *minecraft) {
if (inventory_item != NULL && inventory_item->count > 0) { if (inventory_item != NULL && inventory_item->count > 0) {
// Copy // Copy
ItemInstance *dropped_item = new ItemInstance; ItemInstance *dropped_item = new ItemInstance;
ALLOC_CHECK(dropped_item);
*dropped_item = *inventory_item; *dropped_item = *inventory_item;
// Update Inventory // Update Inventory

View File

@ -113,8 +113,8 @@ static std::vector<unsigned char *> get_players_in_level(unsigned char *level) {
return *(std::vector<unsigned char *> *) (level + Level_players_property_offset); return *(std::vector<unsigned char *> *) (level + Level_players_property_offset);
} }
// Get Player's Username // Get Player's Username
static std::string get_player_username(unsigned char *player) { static std::string *get_player_username(unsigned char *player) {
return *(char **) (player + Player_username_property_offset); return (std::string *) (player + Player_username_property_offset);
} }
// Get Level From Minecraft // Get Level From Minecraft
static unsigned char *get_level(unsigned char *minecraft) { static unsigned char *get_level(unsigned char *minecraft) {
@ -130,7 +130,7 @@ static void find_players(unsigned char *minecraft, std::string target_username,
for (std::size_t i = 0; i < players.size(); i++) { for (std::size_t i = 0; i < players.size(); i++) {
// Iterate Players // Iterate Players
unsigned char *player = players[i]; unsigned char *player = players[i];
std::string username = get_player_username(player); std::string username = *get_player_username(player);
if (all_players || username == target_username) { if (all_players || username == target_username) {
// Run Callback // Run Callback
(*callback)(minecraft, username, player); (*callback)(minecraft, username, player);
@ -390,13 +390,13 @@ static unsigned char *ServerSideNetworkHandler_onReady_ClientGeneration_ServerSi
// Check If Player Is Null // Check If Player Is Null
if (player != NULL) { if (player != NULL) {
// Get Data // Get Data
char *username = (char *) *(unsigned char **) (player + Player_username_property_offset); std::string *username = (std::string *) (player + Player_username_property_offset);
unsigned char *minecraft = *(unsigned char **) (server_side_network_handler + ServerSideNetworkHandler_minecraft_property_offset); unsigned char *minecraft = *(unsigned char **) (server_side_network_handler + ServerSideNetworkHandler_minecraft_property_offset);
unsigned char *rak_peer = get_rak_peer(minecraft); unsigned char *rak_peer = get_rak_peer(minecraft);
char *ip = get_rak_net_guid_ip(rak_peer, *guid); char *ip = get_rak_net_guid_ip(rak_peer, *guid);
// Log // Log
INFO("%s Has Joined (IP: %s)", username, ip); INFO("%s Has Joined (IP: %s)", username->c_str(), ip);
} }
// Return // Return

View File

@ -300,7 +300,7 @@ static uint32_t Player_drop_vtable_offset = 0x208;
static Mob_getWalkingSpeedModifier_t Player_getWalkingSpeedModifier = (Mob_getWalkingSpeedModifier_t) 0x8ea0c; static Mob_getWalkingSpeedModifier_t Player_getWalkingSpeedModifier = (Mob_getWalkingSpeedModifier_t) 0x8ea0c;
static uint32_t Player_username_property_offset = 0xbf4; // char * static uint32_t Player_username_property_offset = 0xbf4; // std::string
static uint32_t Player_inventory_property_offset = 0xbe0; // Inventory * static uint32_t Player_inventory_property_offset = 0xbe0; // Inventory *
// LocalPlayer // LocalPlayer