@@ -1247,47 +1247,44 @@ bool CStaticFunctionDefinitions::SetElementAngularVelocity(CClientEntity& Entity
1247
1247
1248
1248
bool CStaticFunctionDefinitions::SetElementParent (CClientEntity& Entity, CClientEntity& Parent, CLuaMain* pLuaMain)
1249
1249
{
1250
- if (&Entity != &Parent && !Entity.IsMyChild (&Parent, true ))
1250
+ if (&Entity == &Parent || Entity.IsMyChild (&Parent, true ))
1251
+ return false ;
1252
+
1253
+ if (Entity.GetType () == CCLIENTCAMERA || Parent.GetType () == CCLIENTCAMERA)
1254
+ return false ;
1255
+
1256
+ if (Entity.GetType () == CCLIENTGUI)
1251
1257
{
1252
- if (Entity.GetType () == CCLIENTCAMERA || Parent.GetType () == CCLIENTCAMERA)
1253
- {
1258
+ if (Parent.GetType () != CCLIENTGUI && &Parent != pLuaMain->GetResource ()->GetResourceGUIEntity ())
1254
1259
return false ;
1255
- }
1256
- else if (Entity.GetType () == CCLIENTGUI)
1257
- {
1258
- if (Parent.GetType () == CCLIENTGUI || &Parent == pLuaMain->GetResource ()->GetResourceGUIEntity ())
1259
- {
1260
- CClientGUIElement& GUIElement = static_cast <CClientGUIElement&>(Entity);
1261
1260
1262
- GUIElement.SetParent (&Parent);
1263
- return true ;
1264
- }
1265
- }
1266
- else
1267
- {
1268
- CClientEntity* pTemp = &Parent;
1269
- CClientEntity* pRoot = m_pRootEntity;
1270
- bool bValidParent = false ;
1271
- while (pTemp != pRoot && pTemp != NULL )
1272
- {
1273
- const char * szTypeName = pTemp->GetTypeName ();
1274
- if (szTypeName && strcmp (szTypeName, " map" ) == 0 )
1275
- {
1276
- bValidParent = true ; // parents must be a map
1277
- break ;
1278
- }
1261
+ CClientGUIElement& GUIElement = static_cast <CClientGUIElement&>(Entity);
1279
1262
1280
- pTemp = pTemp->GetParent ();
1281
- }
1263
+ GUIElement.SetParent (&Parent);
1264
+ return true ;
1265
+ }
1282
1266
1283
- // Make sure the entity we move is a client entity or we get a problem
1284
- if (bValidParent && Entity.IsLocalEntity ())
1285
- {
1286
- // Set the new parent
1287
- Entity.SetParent (&Parent);
1288
- return true ;
1289
- }
1267
+ CClientEntity* pTemp = &Parent;
1268
+ CClientEntity* pRoot = m_pRootEntity;
1269
+ bool bValidParent = false ;
1270
+ while (pTemp != pRoot && pTemp != NULL )
1271
+ {
1272
+ const char * szTypeName = pTemp->GetTypeName ();
1273
+ if (szTypeName && strcmp (szTypeName, " map" ) == 0 )
1274
+ {
1275
+ bValidParent = true ; // parents must be a map
1276
+ break ;
1290
1277
}
1278
+
1279
+ pTemp = pTemp->GetParent ();
1280
+ }
1281
+
1282
+ // Make sure the entity we move is a client entity or we get a problem
1283
+ if (bValidParent && Entity.IsLocalEntity ())
1284
+ {
1285
+ // Set the new parent
1286
+ Entity.SetParent (&Parent);
1287
+ return true ;
1291
1288
}
1292
1289
1293
1290
return false ;
0 commit comments