CAction *CActionFactory::create (TCLEntityId slot, TActionCode code) { if (RegisteredAction.size() <= code || RegisteredAction[code].first == NULL) { nlwarning ("CActionFactory::create() try to create an unknown action (%u)", code); return NULL; } else if (RegisteredAction[code].second.empty()) { // no action left in the store CAction *action = RegisteredAction[code].first (); // execute the factory function //nlinfo( "No action in store for code %u, creating action (total %u, total for code %u)", code, getNbActionsInStore(), getNbActionsInStore(action->Code) ); action->Code = code; action->PropertyCode = code; // default, set the property code to the action code (see create(TProperty,TPropIndex)) action->Slot = slot; action->reset(); return action; } else { // pop an action off the store CAction *action = RegisteredAction[code].second.back(); //nlinfo( "Found action in store for code %u (total %u, total for code %u)", code, getNbActionsInStore(), getNbActionsInStore(action->Code) ); RegisteredAction[code].second.pop_back(); action->reset(); action->Slot = slot; action->PropertyCode = code; return action; } }