diff options
Diffstat (limited to 'src/undo.cpp')
-rw-r--r-- | src/undo.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/undo.cpp b/src/undo.cpp index c26ab1b..627a0d5 100644 --- a/src/undo.cpp +++ b/src/undo.cpp @@ -231,20 +231,24 @@ void History_Entry_End(memory *Memory) } static void -History_Purge(memory *Memory, history_entry_list *History, uint64 ActionCount_Total, uint64 ActionOffset_Total, uint64 PurgeSize) +History_Purge(memory *Memory, history_entry_list *History, uint64 ActionCount_Total, uint64 ActionOffset_Total, uint64 PurgeSize, uint16 PurgeCount = 0) { int Size = 0; int EntryIndex = 0; int ActionIndex = 0; int ActionCount = 0; - while (Size < PurgeSize) { + bool32 Test = 1; + while (Test) { history_entry *Entry = &History->Entry[EntryIndex]; ActionCount += Entry->NumberOfActions; + if (ActionCount >= 4060) + int b = 0; while (ActionIndex < ActionCount) { Size += History_GetActionSize(History, ActionIndex); ActionIndex++; } EntryIndex++; + Test = (PurgeCount == 0) ? (Size < PurgeSize) : (EntryIndex < PurgeCount); } int EntryCount = (EntryIndex + 1); { @@ -282,8 +286,10 @@ static void History_Action_Add(memory *Memory, history_action ActionData, void * Entry = &History->Entry[History->EntryPlayhead - 1]; Info = History_GetTreeInfo(History, History->EntryPlayhead - 1); } - if (Info.ActionCount_Total > MAX_HISTORY_ACTIONS) { - Assert(0); + if (Info.ActionCount_Total >= MAX_HISTORY_ACTIONS) { + History_Purge(Memory, History, Info.ActionCount_Total, Info.ActionOffset_Total, ActionData.Size * 4, History->NumberOfEntries / 4); + Entry = &History->Entry[History->EntryPlayhead - 1]; + Info = History_GetTreeInfo(History, History->EntryPlayhead - 1); } history_action *Action = &History->Action[Info.ActionCount_Total]; |