Fix item updates in various scenarious

This commit is contained in:
Carl Philipp Klemm 2026-04-01 14:49:30 +02:00
parent 34769049f9
commit 9648c7c040
3 changed files with 22 additions and 12 deletions

View file

@ -161,26 +161,34 @@ Item& Item::operator=(const ItemData& other)
void Item::requestUpdate(ItemUpdateRequest update)
{
if(!hasChanged(update.payload))
assert(update.type != ITEM_UPDATE_INVALID);
if(update.type != ITEM_UPDATE_LOADED && value_ == update.payload.getValue())
return;
if(update.type == ITEM_UPDATE_ACTOR && override_)
return;
if(update.type != ITEM_UPDATE_LOADED
&& (programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY))
qDebug()<<"Item Update Request for"<<getName()<<" type "<<update.type<<" value "<<update.payload.getValue();
if(update.type != ITEM_UPDATE_LOADED &&
update.type != ITEM_UPDATE_BACKEND &&
(programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY))
enactValue(update.payload.getValue());
*this = update.payload;
update.payload = *this;
if(update.type == ITEM_UPDATE_LOADED)
if(update.type != ITEM_UPDATE_LOADED)
{
value_ = update.payload.getValue();
}
else
{
name_ = update.payload.getName();
//itemId_ = update.payload.id();
hidden_ = update.payload.isHidden();
actors_.clear();
for(std::shared_ptr<Actor>& actor : update.newActors)
addActor(actor);
}
update.payload = *this;
updated(update);
}
@ -286,6 +294,7 @@ ItemUpdateRequest Item::createValueUpdateRequest(uint8_t value,
bool withActors)
{
ItemUpdateRequest update;
update.type = type;
update.payload = *this;
update.payload.setValueData(value);
if(withActors)