use bit_cast now that resource_dasm is required
This commit is contained in:
+6
-10
@@ -1691,22 +1691,18 @@ ChatCommandDefinition cc_makeobj(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encode_float = [](float z) -> uint32_t {
|
|
||||||
return *reinterpret_cast<uint32_t*>(&z);
|
|
||||||
};
|
|
||||||
|
|
||||||
unordered_map<string, uint32_t> label_writes{
|
unordered_map<string, uint32_t> label_writes{
|
||||||
{"base_type_high", base_type_high},
|
{"base_type_high", base_type_high},
|
||||||
{"floor_low", a.c->floor},
|
{"floor_low", a.c->floor},
|
||||||
{"pos_x", encode_float(pos.x)},
|
{"pos_x", std::bit_cast<float>(pos.x)},
|
||||||
{"pos_y", encode_float(pos.y)},
|
{"pos_y", std::bit_cast<float>(pos.y)},
|
||||||
{"pos_z", encode_float(pos.z)},
|
{"pos_z", std::bit_cast<float>(pos.z)},
|
||||||
{"angle_x", angle.x},
|
{"angle_x", angle.x},
|
||||||
{"angle_y", angle.y},
|
{"angle_y", angle.y},
|
||||||
{"angle_z", angle.z},
|
{"angle_z", angle.z},
|
||||||
{"param1", encode_float(param123.x)},
|
{"param1", std::bit_cast<float>(param123.x)},
|
||||||
{"param2", encode_float(param123.y)},
|
{"param2", std::bit_cast<float>(param123.y)},
|
||||||
{"param3", encode_float(param123.z)},
|
{"param3", std::bit_cast<float>(param123.z)},
|
||||||
{"param4", param456.x},
|
{"param4", param456.x},
|
||||||
{"param5", param456.y},
|
{"param5", param456.y},
|
||||||
{"param6", param456.z},
|
{"param6", param456.z},
|
||||||
|
|||||||
+2
-13
@@ -62,17 +62,6 @@ using AttackData = BattleParamsIndex::AttackData;
|
|||||||
using ResistData = BattleParamsIndex::ResistData;
|
using ResistData = BattleParamsIndex::ResistData;
|
||||||
using MovementData = BattleParamsIndex::MovementData;
|
using MovementData = BattleParamsIndex::MovementData;
|
||||||
|
|
||||||
// bit_cast isn't in the standard place on macOS (it is apparently implicitly
|
|
||||||
// included by resource_dasm, but newserv can be built without resource_dasm)
|
|
||||||
// and I'm too lazy to go find the right header to include
|
|
||||||
template <typename ToT, typename FromT>
|
|
||||||
ToT as_type(const FromT& v) {
|
|
||||||
static_assert(sizeof(FromT) == sizeof(ToT), "types are not the same size");
|
|
||||||
ToT ret;
|
|
||||||
memcpy(&ret, &v, sizeof(ToT));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* name_for_header_episode_number(uint8_t episode) {
|
static const char* name_for_header_episode_number(uint8_t episode) {
|
||||||
static const array<const char*, 3> names = {"Episode1", "Episode2", "Episode4"};
|
static const array<const char*, 3> names = {"Episode1", "Episode2", "Episode4"};
|
||||||
try {
|
try {
|
||||||
@@ -3319,7 +3308,7 @@ std::string disassemble_quest_script(
|
|||||||
case Type::FLOAT32: {
|
case Type::FLOAT32: {
|
||||||
float v = cmd_r.get_f32l();
|
float v = cmd_r.get_f32l();
|
||||||
if (def->flags & F_PUSH_ARG) {
|
if (def->flags & F_PUSH_ARG) {
|
||||||
arg_stack_values.emplace_back(ArgStackValue::Type::INT, as_type<uint32_t>(v));
|
arg_stack_values.emplace_back(ArgStackValue::Type::INT, std::bit_cast<uint32_t>(v));
|
||||||
}
|
}
|
||||||
dasm_arg = std::format("{:g}", v);
|
dasm_arg = std::format("{:g}", v);
|
||||||
break;
|
break;
|
||||||
@@ -3444,7 +3433,7 @@ std::string disassemble_quest_script(
|
|||||||
dasm_arg = std::format("f{}", arg_value.as_int);
|
dasm_arg = std::format("f{}", arg_value.as_int);
|
||||||
break;
|
break;
|
||||||
case ArgStackValue::Type::INT:
|
case ArgStackValue::Type::INT:
|
||||||
dasm_arg = std::format("{:g}", as_type<float>(arg_value.as_int));
|
dasm_arg = std::format("{:g}", std::bit_cast<float>(arg_value.as_int));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dasm_arg = "/* invalid-type */";
|
dasm_arg = "/* invalid-type */";
|
||||||
|
|||||||
Reference in New Issue
Block a user