| 2337 | }; |
| 2338 | |
| 2339 | void DispatchMessagesFunction(dmMessage::Message* message, void* user_ptr) |
| 2340 | { |
| 2341 | DispatchMessagesContext* context = (DispatchMessagesContext*) user_ptr; |
| 2342 | Collection* collection = context->m_Collection; |
| 2343 | |
| 2344 | Instance* instance = GetInstanceFromIdentifier(collection, message->m_Receiver.m_Path); |
| 2345 | if (instance == 0x0) |
| 2346 | { |
| 2347 | DM_HASH_REVERSE_MEM(hash_ctx, 512); |
| 2348 | const dmMessage::URL* sender = &message->m_Sender; |
| 2349 | const char* socket_name = dmMessage::GetSocketName(sender->m_Socket); |
| 2350 | const char* path_name = dmHashReverseSafe64Alloc(&hash_ctx, sender->m_Path); |
| 2351 | const char* fragment_name = dmHashReverseSafe64Alloc(&hash_ctx, sender->m_Fragment); |
| 2352 | |
| 2353 | dmLogError("Instance '%s' could not be found when dispatching message '%s' sent from %s:%s#%s", |
| 2354 | dmHashReverseSafe64Alloc(&hash_ctx, message->m_Receiver.m_Path), |
| 2355 | dmHashReverseSafe64Alloc(&hash_ctx, message->m_Id), |
| 2356 | socket_name, path_name, fragment_name); |
| 2357 | |
| 2358 | context->m_Success = false; |
| 2359 | return; |
| 2360 | } |
| 2361 | if (message->m_Descriptor != 0) |
| 2362 | { |
| 2363 | dmDDF::Descriptor* descriptor = (dmDDF::Descriptor*)message->m_Descriptor; |
| 2364 | if (descriptor == dmGameObjectDDF::AcquireInputFocus::m_DDFDescriptor) |
| 2365 | { |
| 2366 | dmGameObject::AcquireInputFocus(collection, instance); |
| 2367 | return; |
| 2368 | } |
| 2369 | else if (descriptor == dmGameObjectDDF::ReleaseInputFocus::m_DDFDescriptor) |
| 2370 | { |
| 2371 | dmGameObject::ReleaseInputFocus(collection, instance); |
| 2372 | return; |
| 2373 | } |
| 2374 | else if (descriptor == dmGameObjectDDF::SetParent::m_DDFDescriptor) |
| 2375 | { |
| 2376 | dmGameObjectDDF::SetParent* sp = (dmGameObjectDDF::SetParent*)message->m_Data; |
| 2377 | dmGameObject::HInstance parent = 0; |
| 2378 | if (sp->m_ParentId != 0) |
| 2379 | { |
| 2380 | parent = dmGameObject::GetInstanceFromIdentifier(context->m_Collection, sp->m_ParentId); |
| 2381 | if (parent == 0) |
| 2382 | dmLogWarning("Could not find parent instance with id '%s'.", dmHashReverseSafe64(sp->m_ParentId)); |
| 2383 | |
| 2384 | } |
| 2385 | uint16_t old_parent = instance->m_Parent; |
| 2386 | |
| 2387 | dmGameObject::Result result = dmGameObject::SetParent(instance, parent); |
| 2388 | |
| 2389 | if (result == dmGameObject::RESULT_OK && old_parent != instance->m_Parent) |
| 2390 | { |
| 2391 | Matrix4 parent_t = Matrix4::identity(); |
| 2392 | if (parent) |
| 2393 | { |
| 2394 | parent_t = collection->m_WorldTransforms[parent->m_Index]; |
| 2395 | } |
| 2396 |
nothing calls this directly
no test coverage detected