Ejemplo n.º 1
0
//Removes a number from the specified column
static int* RemoveCol(int* puzzle, int c, int value) {
	int i;
	for (i = 0; i < 9; i++)
		puzzle[SUDOKU_INDEX(i,c)] = RemoveSingle(puzzle[SUDOKU_INDEX(i,c)],
				value);
	return puzzle;
}
Ejemplo n.º 2
0
//Removes a number from the specified row
static int* RemoveRow(int* puzzle, int r, int value) {
	int i;
	for (i = 0; i < 9; i++)
		puzzle[SUDOKU_INDEX(r,i)] = RemoveSingle(puzzle[SUDOKU_INDEX(r,i)],
				value);
	return puzzle;
}
Ejemplo n.º 3
0
//Removes a number from the specified box
//box is defined by lowest value row & column
//i.e. middle box is 3,3
static int* RemoveBox(int* puzzle, int rowbox, int colbox, int value) {
	int i, n;
	for (i = rowbox; i < rowbox + 3; i++)
		for (n = colbox; n < colbox + 3; n++)
			puzzle[SUDOKU_INDEX(i,n)] = RemoveSingle(puzzle[SUDOKU_INDEX(i,n)],
					value);
	return puzzle;
}
Ejemplo n.º 4
0
void FLatentActionManager::ProcessLatentActions(UObject* InObject, float DeltaTime)
{
    for (FActionsForObject::TIterator It(ActionsToRemoveMap); It; ++It)
    {
        auto ActionList = GetActionListForObject(It.Key());
        auto ActionToRemoveListPtr = It.Value();
        if (ActionToRemoveListPtr.IsValid() && ActionList)
        {
            for (auto PendingActionToKill : *ActionToRemoveListPtr)
            {
                const int32 RemovedNum = ActionList->RemoveSingle(PendingActionToKill.Key, PendingActionToKill.Value);
                auto Action = PendingActionToKill.Value;
                if (RemovedNum && Action)
                {
                    Action->NotifyActionAborted();
                    delete Action;
                }
            }
        }
    }
    ActionsToRemoveMap.Empty();

    //@TODO: K2: Very inefficient code right now
    if (InObject != NULL)
    {
        if (!ProcessedThisFrame.Contains(InObject))
        {
            if (FActionList* ObjectActionList = GetActionListForObject(InObject))
            {
                TickLatentActionForObject(DeltaTime, *ObjectActionList, InObject);
                ProcessedThisFrame.Add(InObject);
            }
        }
    }
    else
    {
        for (FObjectToActionListMap::TIterator ObjIt(ObjectToActionListMap); ObjIt; ++ObjIt)
        {
            TWeakObjectPtr<UObject> WeakPtr = ObjIt.Key();
            UObject* Object = WeakPtr.Get();
            auto ObjectActionListPtr = ObjIt.Value().Get();
            check(ObjectActionListPtr);
            FActionList& ObjectActionList = *ObjectActionListPtr;

            if (Object != NULL)
            {
                // Tick all outstanding actions for this object
                if (ObjectActionList.Num() > 0)
                {
                    if (!ProcessedThisFrame.Contains(Object))
                    {
                        TickLatentActionForObject(DeltaTime, ObjectActionList, Object);
                        ensure(ObjectActionListPtr == ObjIt.Value().Get());
                        ProcessedThisFrame.Add(Object);
                    }
                }
            }
            else
            {
                // Terminate all outstanding actions for this object, which has been GCed
                for (TMultiMap<int32, FPendingLatentAction*>::TConstIterator It(ObjectActionList); It; ++It)
                {
                    FPendingLatentAction* Action = It.Value();
                    Action->NotifyObjectDestroyed();
                    delete Action;
                }
                ObjectActionList.Empty();
            }

            // Remove the entry if there are no pending actions remaining for this object (or if the object was NULLed and cleaned up)
            if (ObjectActionList.Num() == 0)
            {
                ObjIt.RemoveCurrent();
            }
        }
    }
}