About Store Forum Documentation Contact



Post Reply 
Sub Objects
Author Message
Ogniok Offline
Member

Post: #1
Sub Objects
Hi!

In my game i have an AI class and in create method I have this code:

Code:
for(Game::ObjParams *cur = &obj; cur; cur = cur->base())
        FREPA(cur->sub_obj)
        {
            Game::ObjParams &o = cur->sub_obj[i];
            switch(Game::World.objType(o.type()))
            {
                case OBJ_ITEM:
                    {
                        ItemEC *subObjItem = &inv.items.New();
                        subObjItem->create(o);

                        //If we want to equip
                        if(T.aiType == AI_VILLAGE_GUARD_1 || T.aiType == AI_VILLAGE_GUARD_2)
                        {
                            if(subObjItem->type == ITEM_WEAPON)
                            {
                                if(subObjItem->power > (inv.slot[SLOT_ARM_R].valid() ? inv.slot[SLOT_ARM_R]().power : 0)) inv.slot[SLOT_ARM_R] = subObjItem;
                            }
                            else if(subObjItem->type == ITEM_ARMOR)
                            {
                                Int slotNumber;

                                slotNumber = -1;

                                switch(subObjItem->type2)
                                {
                                    case ARMOR_SHIELD:
                                        slotNumber = SLOT_ARM_L;
                                        break;
                                    case ARMOR_HELMET:
                                        slotNumber = SLOT_HEAD;
                                        break;
                                    case ARMOR_BODY:
                                        slotNumber = SLOT_BODY;
                                        break;
                                    case ARMOR_PANTS:
                                        slotNumber = SLOT_PANTS;
                                        break;
                                    case ARMOR_GAUNTLET:
                                        slotNumber = SLOT_GAUNTLET;
                                        break;
                                    case ARMOR_BOOT:
                                        slotNumber = SLOT_BOOT;
                                        break;
                                    case ARMOR_NECK:
                                        slotNumber = SLOT_NECK;
                                        break;
                                    case ARMOR_HAND:
                                        slotNumber = SLOT_HAND_R;
                                        break;
                                }

                                if(slotNumber > -1)
                                {
                                    if(subObjItem->defence > (inv.slot[slotNumber].valid() ? inv.slot[slotNumber]().defence : 0)) inv.slot[slotNumber] = subObjItem;
                                }
                            }
                        }
                    }
                    break;
            }
        }

This code equip character with the best from his inventory. Items in inventory are sub objects of this character.

When every(5) character has only one sub object the game is loading 2-3 seconds. But, when 5 characters has one sub object and 2 character has 5 sub object the game is loading 10 seconds. The fade persist 2-3 second and in the next 7 seconds I can see the game but with only 1FPS. But after 20 seconds it works fast.

Is that a problem with my code, computer or engine?
(This post was last modified: 05-09-2010 12:45 PM by Ogniok.)
05-09-2010 10:18 AM
Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #2
RE: Sub Objects
on my computer loading with some characters with 1-4 sub objs game is loading ~5 seconds.
05-09-2010 12:31 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Sub Objects
speed is proportional to size of loaded files (typically mesh material textures)
always any of those are loaded only once from disk, and later kept in memory
05-09-2010 02:08 PM
Find all posts by this user Quote this message in a reply
Post Reply