mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-04 16:23:52 +00:00
feat: propagate OBJECT_FIELD_SCALE_X through creature and GO spawn pipeline
Reads OBJECT_FIELD_SCALE_X (field 4, cross-expansion) from CREATE_OBJECT update fields and passes it through the full creature and game object spawn chain: game_handler callbacks → pending spawn structs → async load results → createInstance() calls. This gives boss giants, gnomes, children, and other non-unit-scale NPCs correct visual size, and ensures scaled GOs (e.g. large treasure chests, oversized plants) render at the server-specified scale rather than always at 1.0. - Added OBJECT_FIELD_SCALE_X to UF enum and all expansion update_fields.json - Added float scale to CreatureSpawnCallback and GameObjectSpawnCallback - Propagated scale through PendingCreatureSpawn, PreparedCreatureModel, PendingGameObjectSpawn, PreparedGameObjectWMO - Used scale in charRenderer/m2Renderer/wmoRenderer createInstance() calls - Sanity-clamped raw float to [0.01, 100.0] range before use
This commit is contained in:
parent
b658743e94
commit
d95abfb607
10 changed files with 85 additions and 24 deletions
|
|
@ -8009,8 +8009,19 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
|
|||
LOG_DEBUG("[Spawn] UNIT guid=0x", std::hex, block.guid, std::dec,
|
||||
" displayId=", unit->getDisplayId(), " at (",
|
||||
unit->getX(), ",", unit->getY(), ",", unit->getZ(), ")");
|
||||
float unitScale = 1.0f;
|
||||
{
|
||||
uint16_t scaleIdx = fieldIndex(UF::OBJECT_FIELD_SCALE_X);
|
||||
if (scaleIdx != 0xFFFF) {
|
||||
uint32_t raw = entity->getField(scaleIdx);
|
||||
if (raw != 0) {
|
||||
std::memcpy(&unitScale, &raw, sizeof(float));
|
||||
if (unitScale <= 0.01f || unitScale > 100.0f) unitScale = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
creatureSpawnCallback_(block.guid, unit->getDisplayId(),
|
||||
unit->getX(), unit->getY(), unit->getZ(), unit->getOrientation());
|
||||
unit->getX(), unit->getY(), unit->getZ(), unit->getOrientation(), unitScale);
|
||||
if (unitInitiallyDead && npcDeathCallback_) {
|
||||
npcDeathCallback_(block.guid);
|
||||
}
|
||||
|
|
@ -8060,8 +8071,19 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
|
|||
// Note: TransportSpawnCallback will be invoked from Application after WMO instance is created
|
||||
}
|
||||
if (go->getDisplayId() != 0 && gameObjectSpawnCallback_) {
|
||||
float goScale = 1.0f;
|
||||
{
|
||||
uint16_t scaleIdx = fieldIndex(UF::OBJECT_FIELD_SCALE_X);
|
||||
if (scaleIdx != 0xFFFF) {
|
||||
uint32_t raw = entity->getField(scaleIdx);
|
||||
if (raw != 0) {
|
||||
std::memcpy(&goScale, &raw, sizeof(float));
|
||||
if (goScale <= 0.01f || goScale > 100.0f) goScale = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
gameObjectSpawnCallback_(block.guid, go->getEntry(), go->getDisplayId(),
|
||||
go->getX(), go->getY(), go->getZ(), go->getOrientation());
|
||||
go->getX(), go->getY(), go->getZ(), go->getOrientation(), goScale);
|
||||
}
|
||||
// Fire transport move callback for transports (position update on re-creation)
|
||||
if (transportGuids_.count(block.guid) && transportMoveCallback_) {
|
||||
|
|
@ -8366,8 +8388,19 @@ void GameHandler::handleUpdateObject(network::Packet& packet) {
|
|||
}
|
||||
}
|
||||
} else if (creatureSpawnCallback_) {
|
||||
float unitScale2 = 1.0f;
|
||||
{
|
||||
uint16_t scaleIdx = fieldIndex(UF::OBJECT_FIELD_SCALE_X);
|
||||
if (scaleIdx != 0xFFFF) {
|
||||
uint32_t raw = entity->getField(scaleIdx);
|
||||
if (raw != 0) {
|
||||
std::memcpy(&unitScale2, &raw, sizeof(float));
|
||||
if (unitScale2 <= 0.01f || unitScale2 > 100.0f) unitScale2 = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
creatureSpawnCallback_(block.guid, unit->getDisplayId(),
|
||||
unit->getX(), unit->getY(), unit->getZ(), unit->getOrientation());
|
||||
unit->getX(), unit->getY(), unit->getZ(), unit->getOrientation(), unitScale2);
|
||||
bool isDeadNow = (unit->getHealth() == 0) ||
|
||||
((unit->getDynamicFlags() & (UNIT_DYNFLAG_DEAD | UNIT_DYNFLAG_LOOTABLE)) != 0);
|
||||
if (isDeadNow && !npcDeathNotified && npcDeathCallback_) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ struct UFNameEntry {
|
|||
|
||||
static const UFNameEntry kUFNames[] = {
|
||||
{"OBJECT_FIELD_ENTRY", UF::OBJECT_FIELD_ENTRY},
|
||||
{"OBJECT_FIELD_SCALE_X", UF::OBJECT_FIELD_SCALE_X},
|
||||
{"UNIT_FIELD_TARGET_LO", UF::UNIT_FIELD_TARGET_LO},
|
||||
{"UNIT_FIELD_TARGET_HI", UF::UNIT_FIELD_TARGET_HI},
|
||||
{"UNIT_FIELD_BYTES_0", UF::UNIT_FIELD_BYTES_0},
|
||||
|
|
@ -52,6 +53,9 @@ static const UFNameEntry kUFNames[] = {
|
|||
{"PLAYER_EXPLORED_ZONES_START", UF::PLAYER_EXPLORED_ZONES_START},
|
||||
{"GAMEOBJECT_DISPLAYID", UF::GAMEOBJECT_DISPLAYID},
|
||||
{"ITEM_FIELD_STACK_COUNT", UF::ITEM_FIELD_STACK_COUNT},
|
||||
{"ITEM_FIELD_DURABILITY", UF::ITEM_FIELD_DURABILITY},
|
||||
{"ITEM_FIELD_MAXDURABILITY", UF::ITEM_FIELD_MAXDURABILITY},
|
||||
{"PLAYER_REST_STATE_EXPERIENCE", UF::PLAYER_REST_STATE_EXPERIENCE},
|
||||
{"CONTAINER_FIELD_NUM_SLOTS", UF::CONTAINER_FIELD_NUM_SLOTS},
|
||||
{"CONTAINER_FIELD_SLOT_1", UF::CONTAINER_FIELD_SLOT_1},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue