Some major changes happend to wasm2c, before I do something stupid...

This commit is contained in:
berendbutje 2023-02-11 12:10:51 +01:00
parent af66bfc82f
commit 049f599d9a
2 changed files with 51 additions and 19 deletions

View File

@ -8644,6 +8644,39 @@ static u32 w2c_f167(u32 w2c_p0) {
} }
void w2c_f168(u32 w2c_p0, u32 w2c_p1) { void w2c_f168(u32 w2c_p0, u32 w2c_p1) {
typedef struct str_long_ {
u32 text;
int length;
void* capacity;
} str_long;
typedef struct str_short_ {
char text[1];
char __pad[10];
char length;
} str_short;
typedef struct str_ {
union {
str_long repr_long;
str_short repr_short;
};
} str;
_Static_assert(sizeof(str_long) == 12, L"str_long needs to be 12 bytes.");
_Static_assert(sizeof(str_short) == 12, L"str_long needs to be 12 bytes.");
_Static_assert(sizeof(str) == 12, L"str_long needs to be 12 bytes.");
printf("get_text(): ");
str* str_input = (str*)&(&w2c_memory)->data[w2c_p1];
// if is_short
if(-1 < str_input->repr_short.length) {
printf("\"%s\" ", str_input->repr_short.text);
} else {
printf("\"%s\" ", (char*)&(&w2c_memory)->data[str_input->repr_long.text]);
}
u32 w2c_l2 = 0, w2c_l3 = 0, w2c_l4 = 0, w2c_l5 = 0, w2c_l6 = 0, w2c_l7 = 0; u32 w2c_l2 = 0, w2c_l3 = 0, w2c_l4 = 0, w2c_l5 = 0, w2c_l6 = 0, w2c_l7 = 0;
FUNC_PROLOGUE; FUNC_PROLOGUE;
u32 w2c_i0, w2c_i1, w2c_i2, w2c_i3; u32 w2c_i0, w2c_i1, w2c_i2, w2c_i3;
@ -8759,6 +8792,17 @@ void w2c_f168(u32 w2c_p0, u32 w2c_p1) {
w2c_i0 += w2c_i1; w2c_i0 += w2c_i1;
w2c_g0 = w2c_i0; w2c_g0 = w2c_i0;
FUNC_EPILOGUE; FUNC_EPILOGUE;
printf("got translated into ");
str* str_output = (str*)&(&w2c_memory)->data[w2c_p0];
// if is_short
if(-1 < str_output->repr_short.length) {
printf("\"%s\" ", str_output->repr_short.text);
} else {
printf("\"%s\" ", (char*)&(&w2c_memory)->data[str_output->repr_long.text]);
}
printf("\n");
} }
static u32 w2c_f169(u32 w2c_p0, u32 w2c_p1, u32 w2c_p2) { static u32 w2c_f169(u32 w2c_p0, u32 w2c_p1, u32 w2c_p2) {

View File

@ -221,22 +221,14 @@ check_rebuff(const flyff::Pointer<flyff::Mover> &buffer, const flyff::Pointer<fl
static_cast<const flyff::ObjectProperty *>(buff->property) static_cast<const flyff::ObjectProperty *>(buff->property)
); );
std::cout << "Current skill level: " << current_skill_level << ", Player skill level: "
<< player_skill_level << std::endl;
if (player_skill_level > current_skill_level) { if (player_skill_level > current_skill_level) {
std::cout << neuz.get_text(buff_property->name)
<< " has to be applied because it is lower level than what " << buffer->name << " has."
<< std::endl;
// Always apply a higher buff. // Always apply a higher buff.
result.push_back(skill_index); result.push_back(skill_index);
} else if (buff->get_time_remaining() < 30 * 1000 && player_skill_level >= current_skill_level) { } else if (buff->get_time_remaining() < 30 * 1000 && player_skill_level >= current_skill_level) {
std::cout << neuz.get_text(buff_property->name) << " has to be applied because the buff is running out."
<< std::endl;
// Refresh the buff. // Refresh the buff.
result.push_back(skill_index); result.push_back(skill_index);
} }
} else { } else {
// std::cout << buff_property->name << " has to be applied because it is lower level than what " << buffer->name << " has." << std::endl;
// Apply the buff. // Apply the buff.
result.push_back(skill_index); result.push_back(skill_index);
} }
@ -474,9 +466,9 @@ void on_keyup_hook(int event_type, const EmscriptenKeyboardEvent *event, void *u
} }
std::cout << "Player has the following " << client.player->skills->size() << " skills" << std::endl; std::cout << "Player has the following " << client.player->skills->size() << " skills" << std::endl;
for(const auto& skill : client.player->skills) { for (const auto &skill: client.player->skills) {
const auto& property = fugg::Client::get_skill_property(skill.id); const auto &property = fugg::Client::get_skill_property(skill.id);
if(property) { if (property) {
std::cout << client.get_text(property->name) << " "; std::cout << client.get_text(property->name) << " ";
} }
std::cout << "(" << skill.id << ") at level " << skill.level << std::endl; std::cout << "(" << skill.id << ") at level " << skill.level << std::endl;
@ -665,7 +657,7 @@ void attacker_script() {
std::string str = "Eating "; std::string str = "Eating ";
str.append(neuz.get_text(food_item->property->name)); str.append(neuz.get_text(food_item->property->name));
neuz.show_message(str); neuz.show_message(str, {0x7F, 0, 0});
client.send_use_item_in_inventory(food_item->index); client.send_use_item_in_inventory(food_item->index);
} else { } else {
@ -735,9 +727,6 @@ void attacker_script() {
} }
} }
std::cout << "Player has " << neuz.player->get_mp() << " / " << neuz.player->get_max_mp() << " MP" << std::endl;
std::cout << "Player has " << neuz.player->get_fp() << " / " << neuz.player->get_max_fp() << " FP" << std::endl;
if (neuz.player->get_fp_percent() != 100) { if (neuz.player->get_fp_percent() != 100) {
auto fatigue_item = flyff::Pointer<flyff::InventoryItem>(nullptr); auto fatigue_item = flyff::Pointer<flyff::InventoryItem>(nullptr);
auto items = player->inventory.begin(); auto items = player->inventory.begin();
@ -784,6 +773,7 @@ void attacker_script() {
current_target = 0; current_target = 0;
neuz.player->selected_target = 0; neuz.player->selected_target = 0;
neuz.player->attack_target = 0;
client.send_clear_target(); client.send_clear_target();
return; return;
} }
@ -791,10 +781,8 @@ void attacker_script() {
} }
if ((neuz.player->get_move_state() == flyff::Object::MoveState::Stand || if (neuz.player->get_move_state() == flyff::Object::MoveState::Stand &&
neuz.player->get_move_state() == flyff::Object::MoveState::PickUp) &&
!neuz.player->is_attacking()) { !neuz.player->is_attacking()) {
std::cout << "Player MoveState: " << client.player->get_move_state() << std::endl;
// Check buffs. // Check buffs.
static constexpr flyff::SkillID buffs_to_check[] = { static constexpr flyff::SkillID buffs_to_check[] = {
@ -863,7 +851,7 @@ void attacker_script() {
client.send_use_skill(flyff::SkillID::Asmodeus); client.send_use_skill(flyff::SkillID::Asmodeus);
return; return;
} }
} else if(neuz.player->get_job() == flyff::JobID::Knight) { } else if (neuz.player->get_job() == flyff::JobID::Knight) {
const auto &off_hand = player->get_equipped_item(flyff::Part::Shield); const auto &off_hand = player->get_equipped_item(flyff::Part::Shield);
if (off_hand && off_hand->item_kind3 == flyff::ItemKind3::Shield) { if (off_hand && off_hand->item_kind3 == flyff::ItemKind3::Shield) {