Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Undo.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

void Undo_AddBrush (brush_t *pBrush)
void Undo_AddBrushList (brush_t *brushlist)
void Undo_AddEntity (entity_t *entity)
void Undo_Clear (void)
void Undo_End (void)
void Undo_EndBrush (brush_t *pBrush)
void Undo_EndBrushList (brush_t *brushlist)
void Undo_EndEntity (entity_t *entity)
int Undo_GetMaxMemorySize (void)
int Undo_GetMaxSize (void)
int Undo_MemorySize (void)
void Undo_Redo (void)
int Undo_RedoAvailable (void)
void Undo_SetMaxMemorySize (int size)
void Undo_SetMaxSize (int size)
void Undo_Start (char *operation)
void Undo_Undo (void)
int Undo_UndoAvailable (void)


Function Documentation

void Undo_AddBrush brush_t pBrush  ) 
 

Definition at line 365 of file Undo.cpp.

References Brush_AddToList(), Brush_FullClone(), Brush_MemorySize(), brush_t, undo_s::brushlist, entity_s::entityId, undo_s::entitylist, g_lastundo, g_undoMemorySize, brush_s::owner, brush_s::ownerId, Sys_Printf(), Undo_BrushInUndo(), and brush_s::undoId.

Referenced by CSG_Subtract(), and Select_SetTexture().

00366 {
00367     if (!g_lastundo)
00368     {
00369         Sys_Printf("Undo_AddBrushList: no last undo.\n");
00370         return;
00371     }
00372     if (g_lastundo->entitylist.next != &g_lastundo->entitylist)
00373     {
00374         Sys_Printf("Undo_AddBrushList: WARNING adding brushes after entity.\n");
00375     }
00376     //if the brush is already in the undo
00377     if (Undo_BrushInUndo(g_lastundo, pBrush))
00378         return;
00379     //clone the brush
00380     brush_t* pClone = Brush_FullClone(pBrush);
00381     //save the ID of the owner entity
00382     pClone->ownerId = pBrush->owner->entityId;
00383     //save the old undo ID for previous undos
00384     pClone->undoId = pBrush->undoId;
00385     Brush_AddToList (pClone, &g_lastundo->brushlist);
00386     //
00387     g_undoMemorySize += Brush_MemorySize(pClone);
00388 }

Here is the call graph for this function:

void Undo_AddBrushList brush_t brushlist  ) 
 

Definition at line 395 of file Undo.cpp.

References Brush_AddToList(), Brush_FullClone(), Brush_MemorySize(), brush_t, undo_s::brushlist, entity_s::eclass, entity_s::entityId, undo_s::entitylist, eclass_s::fixedsize, g_lastundo, g_undoMemorySize, brush_s::next, NULL, brush_s::owner, brush_s::ownerId, Sys_Printf(), Undo_AddEntity(), Undo_BrushInUndo(), and brush_s::undoId.

Referenced by Drag_Setup(), CMainFrame::OnBrush3sided(), CMainFrame::OnBrush4sided(), CMainFrame::OnBrush5sided(), CMainFrame::OnBrush6sided(), CMainFrame::OnBrush7sided(), CMainFrame::OnBrush8sided(), CMainFrame::OnBrush9sided(), CMainFrame::OnBrushArbitrarysided(), CMainFrame::OnBrushFlipx(), CMainFrame::OnBrushFlipy(), CMainFrame::OnBrushFlipz(), CMainFrame::OnBrushMakecone(), CMainFrame::OnBrushPrimitivesSphere(), CMainFrame::OnBrushRotatex(), CMainFrame::OnBrushRotatey(), CMainFrame::OnBrushRotatez(), CMainFrame::OnClipSelected(), CMainFrame::OnCurveDeletecolumn(), CMainFrame::OnCurveDeleteFirstcolumn(), CMainFrame::OnCurveDeleteFirstrow(), CMainFrame::OnCurveDeleteLastcolumn(), CMainFrame::OnCurveDeleteLastrow(), CMainFrame::OnCurveDeleterow(), CMainFrame::OnCurveInsertAddcolumn(), CMainFrame::OnCurveInsertAddrow(), CMainFrame::OnCurveInsertcolumn(), CMainFrame::OnCurveInsertInsertcolumn(), CMainFrame::OnCurveInsertInsertrow(), CMainFrame::OnCurveInsertrow(), CMainFrame::OnCurveMoreendcapsbevelsSquarebevel(), CMainFrame::OnCurveMoreendcapsbevelsSquareendcap(), CMainFrame::OnCurvePatchbevel(), CMainFrame::OnCurvePatchcone(), CMainFrame::OnCurvePatchdensetube(), CMainFrame::OnCurvePatchendcap(), CMainFrame::OnCurvePatchsquare(), CMainFrame::OnCurvePatchtube(), CMainFrame::OnCurvePatchverydensetube(), CMainFrame::OnCurveSimplepatchmesh(), CMainFrame::OnCurveThicken(), CMainFrame::OnSelectionArbitraryrotation(), CMainFrame::OnSelectionCsgmerge(), CMainFrame::OnSelectionDelete(), CMainFrame::OnSelectionMakeDetail(), CMainFrame::OnSelectionMakehollow(), CMainFrame::OnSelectionMakeStructural(), CMainFrame::OnSelectionMovedown(), CMainFrame::OnSelectScale(), and CMainFrame::OnSplitSelected().

00396 {
00397     brush_t *pBrush;
00398 
00399     if (!g_lastundo)
00400     {
00401         Sys_Printf("Undo_AddBrushList: no last undo.\n");
00402         return;
00403     }
00404     if (g_lastundo->entitylist.next != &g_lastundo->entitylist)
00405     {
00406         Sys_Printf("Undo_AddBrushList: WARNING adding brushes after entity.\n");
00407     }
00408     //copy the brushes to the undo
00409     for (pBrush = brushlist->next ; pBrush != NULL && pBrush != brushlist; pBrush=pBrush->next)
00410     {
00411         //if the brush is already in the undo
00412         if (Undo_BrushInUndo(g_lastundo, pBrush))
00413             continue;
00414         // do we need to store this brush's entity in the undo?
00415         // if it's a fixed size entity, the brush that reprents it is not really relevant, it's used for selecting and moving around
00416         // what we want to store for undo is the owner entity, epairs and origin/angle stuff
00417         //++timo FIXME: if the entity is not fixed size I don't know, so I don't do it yet
00418         if (pBrush->owner->eclass->fixedsize == 1)
00419             Undo_AddEntity( pBrush->owner );
00420         //clone the brush
00421         brush_t* pClone = Brush_FullClone(pBrush);
00422         //save the ID of the owner entity
00423         pClone->ownerId = pBrush->owner->entityId;
00424         //save the old undo ID from previous undos
00425         pClone->undoId = pBrush->undoId;
00426         Brush_AddToList (pClone, &g_lastundo->brushlist);
00427         //
00428         g_undoMemorySize += Brush_MemorySize(pClone);
00429     }
00430 }

Here is the call graph for this function:

void Undo_AddEntity entity_t entity  ) 
 

Definition at line 480 of file Undo.cpp.

References Entity_AddToList(), Entity_Clone(), Entity_MemorySize(), Entity_RemoveFromList(), undo_s::entitylist, g_lastundo, g_undoMemorySize, Sys_Printf(), and Undo_EntityInUndo().

Referenced by CMainFrame::OnSelectionDelete(), and Undo_AddBrushList().

00481 {
00482     entity_t* pClone;
00483 
00484     if (!g_lastundo)
00485     {
00486         Sys_Printf("Undo_AddEntity: no last undo.\n");
00487         return;
00488     }
00489     //if the entity is already in the undo
00490     if (Undo_EntityInUndo(g_lastundo, entity))
00491         return;
00492     //clone the entity
00493     pClone = Entity_Clone(entity);
00494     //NOTE: Entity_Clone adds the entity to the entity list
00495     //      so we remove it from that list here
00496     Entity_RemoveFromList(pClone);
00497     //save the old undo ID for previous undos
00498     pClone->undoId = entity->undoId;
00499     //save the entity ID (we need a full clone)
00500     pClone->entityId = entity->entityId;
00501     //
00502     Entity_AddToList(pClone, &g_lastundo->entitylist);
00503     //
00504     g_undoMemorySize += Entity_MemorySize(pClone);
00505 }

Here is the call graph for this function:

void Undo_Clear void   ) 
 

Definition at line 136 of file Undo.cpp.

References Brush_Free(), Brush_MemorySize(), brush_t, undo_s::brushlist, Entity_Free(), Entity_MemorySize(), undo_s::entitylist, free(), g_lastundo, g_undoId, g_undolist, g_undoMemorySize, g_undoSize, brush_s::next, undo_s::next, NULL, Undo_ClearRedo(), and undo_t.

Referenced by Undo_SetMaxMemorySize(), and Undo_SetMaxSize().

00137 {
00138     undo_t *undo, *nextundo;
00139     brush_t *pBrush, *pNextBrush;
00140     entity_t *pEntity, *pNextEntity;
00141 
00142     Undo_ClearRedo();
00143     for (undo = g_undolist; undo; undo = nextundo)
00144     {
00145         nextundo = undo->next;
00146         for (pBrush = undo->brushlist.next ; pBrush != NULL && pBrush != &undo->brushlist ; pBrush = pNextBrush)
00147         {
00148             pNextBrush = pBrush->next;
00149             g_undoMemorySize -= Brush_MemorySize(pBrush);
00150             Brush_Free(pBrush);
00151         }
00152         for (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = pNextEntity)
00153         {
00154             pNextEntity = pEntity->next;
00155             g_undoMemorySize -= Entity_MemorySize(pEntity);
00156             Entity_Free(pEntity);
00157         }
00158         g_undoMemorySize -= sizeof(undo_t);
00159         free(undo);
00160     }
00161     g_undolist = NULL;
00162     g_lastundo = NULL;
00163     g_undoSize = 0;
00164     g_undoMemorySize = 0;
00165     g_undoId = 1;
00166 }

Here is the call graph for this function:

void Undo_End void   ) 
 

Definition at line 539 of file Undo.cpp.

References undo_s::done, g_lastundo, g_undolist, g_undoMemorySize, and Undo_FreeFirstUndo().

Referenced by Drag_MouseUp(), Map_ImportBuffer(), CMainFrame::OnBrush3sided(), CMainFrame::OnBrush4sided(), CMainFrame::OnBrush5sided(), CMainFrame::OnBrush6sided(), CMainFrame::OnBrush7sided(), CMainFrame::OnBrush8sided(), CMainFrame::OnBrush9sided(), CMainFrame::OnBrushArbitrarysided(), CMainFrame::OnBrushFlipx(), CMainFrame::OnBrushFlipy(), CMainFrame::OnBrushFlipz(), CMainFrame::OnBrushMakecone(), CMainFrame::OnBrushPrimitivesSphere(), CMainFrame::OnBrushRotatex(), CMainFrame::OnBrushRotatey(), CMainFrame::OnBrushRotatez(), CMainFrame::OnClipSelected(), CMainFrame::OnCurveDeletecolumn(), CMainFrame::OnCurveDeleteFirstcolumn(), CMainFrame::OnCurveDeleteFirstrow(), CMainFrame::OnCurveDeleteLastcolumn(), CMainFrame::OnCurveDeleteLastrow(), CMainFrame::OnCurveDeleterow(), CMainFrame::OnCurveInsertAddcolumn(), CMainFrame::OnCurveInsertAddrow(), CMainFrame::OnCurveInsertcolumn(), CMainFrame::OnCurveInsertInsertcolumn(), CMainFrame::OnCurveInsertInsertrow(), CMainFrame::OnCurveInsertrow(), CMainFrame::OnCurveMoreendcapsbevelsSquarebevel(), CMainFrame::OnCurveMoreendcapsbevelsSquareendcap(), CMainFrame::OnCurvePatchbevel(), CMainFrame::OnCurvePatchcone(), CMainFrame::OnCurvePatchdensetube(), CMainFrame::OnCurvePatchendcap(), CMainFrame::OnCurvePatchsquare(), CMainFrame::OnCurvePatchtube(), CMainFrame::OnCurvePatchverydensetube(), CMainFrame::OnCurveSimplepatchmesh(), CMainFrame::OnCurveThicken(), CMainFrame::OnSelectionArbitraryrotation(), CMainFrame::OnSelectionCsgmerge(), CMainFrame::OnSelectionCsgsubtract(), CMainFrame::OnSelectionDelete(), CMainFrame::OnSelectionMakeDetail(), CMainFrame::OnSelectionMakehollow(), CMainFrame::OnSelectionMakeStructural(), CMainFrame::OnSelectionMovedown(), CMainFrame::OnSelectScale(), CMainFrame::OnSplitSelected(), Select_SetTexture(), and Undo_Redo().

00540 {
00541     if (!g_lastundo)
00542     {
00543         //Sys_Printf("Undo_End: no last undo.\n");
00544         return;
00545     }
00546     if (g_lastundo->done)
00547     {
00548         //Sys_Printf("Undo_End: last undo already finished.\n");
00549         return;
00550     }
00551     g_lastundo->done = true;
00552 
00553     //undo memory size is bound to a max
00554     while (g_undoMemorySize > g_undoMaxMemorySize)
00555     {
00556         //always keep one undo
00557         if (g_undolist == g_lastundo) break;
00558         Undo_FreeFirstUndo();
00559     }
00560     //
00561     //Sys_Printf("undo size = %d, undo memory = %d\n", g_undoSize, g_undoMemorySize);
00562 }

Here is the call graph for this function:

void Undo_EndBrush brush_t pBrush  ) 
 

Definition at line 437 of file Undo.cpp.

References brush_t, undo_s::done, g_lastundo, undo_s::id, and brush_s::undoId.

Referenced by CSG_Subtract(), Map_ImportBuffer(), and Select_SetTexture().

00438 {
00439     if (!g_lastundo)
00440     {
00441         //Sys_Printf("Undo_End: no last undo.\n");
00442         return;
00443     }
00444     if (g_lastundo->done)
00445     {
00446         //Sys_Printf("Undo_End: last undo already finished.\n");
00447         return;
00448     }
00449     pBrush->undoId = g_lastundo->id;
00450 }

void Undo_EndBrushList brush_t brushlist  ) 
 

Definition at line 457 of file Undo.cpp.

References brush_t, undo_s::done, g_lastundo, undo_s::id, brush_s::next, NULL, and brush_s::undoId.

Referenced by Drag_MouseUp(), CMainFrame::OnBrush3sided(), CMainFrame::OnBrush4sided(), CMainFrame::OnBrush5sided(), CMainFrame::OnBrush6sided(), CMainFrame::OnBrush7sided(), CMainFrame::OnBrush8sided(), CMainFrame::OnBrush9sided(), CMainFrame::OnBrushArbitrarysided(), CMainFrame::OnBrushFlipx(), CMainFrame::OnBrushFlipy(), CMainFrame::OnBrushFlipz(), CMainFrame::OnBrushMakecone(), CMainFrame::OnBrushPrimitivesSphere(), CMainFrame::OnBrushRotatex(), CMainFrame::OnBrushRotatey(), CMainFrame::OnBrushRotatez(), CMainFrame::OnClipSelected(), CMainFrame::OnCurveDeletecolumn(), CMainFrame::OnCurveDeleteFirstcolumn(), CMainFrame::OnCurveDeleteFirstrow(), CMainFrame::OnCurveDeleteLastcolumn(), CMainFrame::OnCurveDeleteLastrow(), CMainFrame::OnCurveDeleterow(), CMainFrame::OnCurveInsertAddcolumn(), CMainFrame::OnCurveInsertAddrow(), CMainFrame::OnCurveInsertcolumn(), CMainFrame::OnCurveInsertInsertcolumn(), CMainFrame::OnCurveInsertInsertrow(), CMainFrame::OnCurveInsertrow(), CMainFrame::OnCurveMoreendcapsbevelsSquarebevel(), CMainFrame::OnCurveMoreendcapsbevelsSquareendcap(), CMainFrame::OnCurvePatchbevel(), CMainFrame::OnCurvePatchcone(), CMainFrame::OnCurvePatchdensetube(), CMainFrame::OnCurvePatchendcap(), CMainFrame::OnCurvePatchsquare(), CMainFrame::OnCurvePatchtube(), CMainFrame::OnCurvePatchverydensetube(), CMainFrame::OnCurveSimplepatchmesh(), CMainFrame::OnCurveThicken(), CMainFrame::OnSelectionArbitraryrotation(), CMainFrame::OnSelectionCsgmerge(), CMainFrame::OnSelectionDelete(), CMainFrame::OnSelectionMakeDetail(), CMainFrame::OnSelectionMakehollow(), CMainFrame::OnSelectionMakeStructural(), CMainFrame::OnSelectionMovedown(), CMainFrame::OnSelectScale(), and CMainFrame::OnSplitSelected().

00458 {
00459     if (!g_lastundo)
00460     {
00461         //Sys_Printf("Undo_End: no last undo.\n");
00462         return;
00463     }
00464     if (g_lastundo->done)
00465     {
00466         //Sys_Printf("Undo_End: last undo already finished.\n");
00467         return;
00468     }
00469     for (brush_t* pBrush = brushlist->next; pBrush != NULL && pBrush != brushlist; pBrush=pBrush->next)
00470     {
00471         pBrush->undoId = g_lastundo->id;
00472     }
00473 }

void Undo_EndEntity entity_t entity  ) 
 

Definition at line 512 of file Undo.cpp.

References undo_s::done, g_lastundo, and undo_s::id.

Referenced by Map_ImportBuffer().

00513 {
00514     if (!g_lastundo)
00515     {
00516         //Sys_Printf("Undo_End: no last undo.\n");
00517         return;
00518     }
00519     if (g_lastundo->done)
00520     {
00521         //Sys_Printf("Undo_End: last undo already finished.\n");
00522         return;
00523     }
00524     if (entity == world_entity)
00525     {
00526         //Sys_Printf("Undo_AddEntity: undo on world entity.\n");
00527         //NOTE: we never delete the world entity when undoing an operation
00528         //      we only transfer the epairs
00529         return;
00530     }
00531     entity->undoId = g_lastundo->id;
00532 }

int Undo_GetMaxMemorySize void   ) 
 

Definition at line 207 of file Undo.cpp.

00208 {
00209     return g_undoMaxMemorySize;
00210 }

int Undo_GetMaxSize void   ) 
 

Definition at line 185 of file Undo.cpp.

00186 {
00187     return g_undoMaxSize;
00188 }

int Undo_MemorySize void   ) 
 

Definition at line 72 of file Undo.cpp.

00073 {
00074     /*
00075     int size;
00076     undo_t *undo;
00077     brush_t *pBrush;
00078     entity_t *pEntity;
00079 
00080     size = 0;
00081     for (undo = g_undolist; undo; undo = undo->next)
00082     {
00083         for (pBrush = undo->brushlist.next ; pBrush != NULL && pBrush != &undo->brushlist ; pBrush = pBrush->next)
00084         {
00085             size += Brush_MemorySize(pBrush);
00086         }
00087         for (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = pEntity->next)
00088         {
00089             size += Entity_MemorySize(pEntity);
00090         }
00091         size += sizeof(undo_t);
00092     }
00093     return size;
00094     */
00095     return g_undoMemorySize;
00096 }

void Undo_Redo void   ) 
 

Definition at line 739 of file Undo.cpp.

References active_brushes, Brush_AddToList(), Brush_MemorySize(), Brush_RemoveFromList(), brush_t, entity_t::brushes, undo_s::brushlist, undo_s::done, entities, Entity_AddToList(), Entity_Free(), Entity_FreeEpairs(), Entity_LinkBrush(), Entity_MemorySize(), Entity_RemoveFromList(), Entity_UnlinkBrush(), entity_s::entityId, undo_s::entitylist, entity_t::epairs, free(), g_bScreenUpdates, g_lastredo, g_lastundo, g_redoId, g_redolist, g_undoMemorySize, undo_s::id, bspbrush_s::next, brush_s::next, undo_s::next, NULL, undo_s::operation, brush_s::owner, brush_s::ownerId, undo_s::prev, brush_s::redoId, Select_Brush(), Select_Deselect(), Sys_Printf(), Sys_UpdateWindows(), Undo_End(), Undo_GeneralStart(), undo_t, W_ALL, and world_entity.

Referenced by CMainFrame::OnEditRedo(), and CMainFrame::OnTogglez().

00740 {
00741     undo_t *redo;
00742     brush_t *pBrush, *pNextBrush;
00743     entity_t *pEntity, *pNextEntity, *pRedoEntity;
00744 
00745     if (!g_lastredo)
00746     {
00747         Sys_Printf("Nothing left to redo.\n");
00748         return;
00749     }
00750     if (g_lastundo)
00751     {
00752         if (!g_lastundo->done)
00753         {
00754             Sys_Printf("WARNING: last undo not finished.\n");
00755         }
00756     }
00757     // get the last redo
00758     redo = g_lastredo;
00759     if (g_lastredo->prev) g_lastredo->prev->next = NULL;
00760     else g_redolist = NULL;
00761     g_lastredo = g_lastredo->prev;
00762     //
00763     Undo_GeneralStart(redo->operation);
00764     // remove current selection
00765     Select_Deselect();
00766     // move "created" brushes back to the last undo
00767     for (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush = pNextBrush)
00768     {
00769         pNextBrush = pBrush->next;
00770         if (pBrush->redoId == redo->id)
00771         {
00772             //move the brush to the undo
00773             Brush_RemoveFromList(pBrush);
00774             Brush_AddToList(pBrush, &g_lastundo->brushlist);
00775             g_undoMemorySize += Brush_MemorySize(pBrush);
00776             pBrush->ownerId = pBrush->owner->entityId;
00777             Entity_UnlinkBrush(pBrush);
00778         }
00779     }
00780     // move "created" entities back to the last undo
00781     for (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)
00782     {
00783         pNextEntity = pEntity->next;
00784         if (pEntity->redoId == redo->id)
00785         {
00786             // check if this entity is in the redo
00787             for (pRedoEntity = redo->entitylist.next; pRedoEntity != NULL && pRedoEntity != &redo->entitylist; pRedoEntity = pRedoEntity->next)
00788             {
00789                 // move brushes to the redo entity
00790                 if (pRedoEntity->entityId == pEntity->entityId)
00791                 {
00792                     pRedoEntity->brushes.next = pEntity->brushes.next;
00793                     pRedoEntity->brushes.prev = pEntity->brushes.prev;
00794                     pEntity->brushes.next = &pEntity->brushes;
00795                     pEntity->brushes.prev = &pEntity->brushes;
00796                 }
00797             }
00798             //
00799             //Entity_Free(pEntity);
00800             //move the entity to the redo
00801             Entity_RemoveFromList(pEntity);
00802             Entity_AddToList(pEntity, &g_lastundo->entitylist);
00803             g_undoMemorySize += Entity_MemorySize(pEntity);
00804         }
00805     }
00806     // add the undo entities back into the entity list
00807     for (pEntity = redo->entitylist.next; pEntity != NULL && pEntity != &redo->entitylist; pEntity = redo->entitylist.next)
00808     {
00809         //if this is the world entity
00810         if (pEntity->entityId == world_entity->entityId)
00811         {
00812             //free the epairs of the world entity
00813             Entity_FreeEpairs(world_entity);
00814             //set back the original epairs
00815             world_entity->epairs = pEntity->epairs;
00816             //free the world_entity clone that stored the epairs
00817             Entity_Free(pEntity);
00818         }
00819         else
00820         {
00821             Entity_RemoveFromList(pEntity);
00822             Entity_AddToList(pEntity, &entities);
00823         }
00824     }
00825     // add the redo brushes back into the selected brushes
00826     for (pBrush = redo->brushlist.next; pBrush != NULL && pBrush != &redo->brushlist; pBrush = redo->brushlist.next)
00827     {
00828         Brush_RemoveFromList(pBrush);
00829         Brush_AddToList(pBrush, &active_brushes);
00830         for (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)
00831         {
00832             if (pEntity->entityId == pBrush->ownerId)
00833             {
00834                 Entity_LinkBrush(pEntity, pBrush);
00835                 break;
00836             }
00837         }
00838         //if the brush is not linked then it should be linked into the world entity
00839         if (pEntity == NULL || pEntity == &entities)
00840         {
00841             Entity_LinkBrush(world_entity, pBrush);
00842         }
00843         //build the brush
00844         //Brush_Build(pBrush);
00845         Select_Brush(pBrush);
00846     }
00847     //
00848     Undo_End();
00849     //
00850     Sys_Printf("%s redone.\n", redo->operation);
00851     //
00852     g_redoId--;
00853     // free the undo
00854     free(redo);
00855     //
00856     g_bScreenUpdates = true; 
00857     Sys_UpdateWindows(W_ALL);
00858 }

Here is the call graph for this function:

int Undo_RedoAvailable void   ) 
 

Definition at line 865 of file Undo.cpp.

Referenced by CMainFrame::OnUpdateEditRedo().

00866 {
00867     if (g_lastredo) return true;
00868     return false;
00869 }

void Undo_SetMaxMemorySize int  size  ) 
 

Definition at line 195 of file Undo.cpp.

References g_undoMaxMemorySize, and Undo_Clear().

00196 {
00197     Undo_Clear();
00198     if (size < 1024) g_undoMaxMemorySize = 1024;
00199     else g_undoMaxMemorySize = size;
00200 }

Here is the call graph for this function:

void Undo_SetMaxSize int  size  ) 
 

Definition at line 173 of file Undo.cpp.

References g_undoMaxSize, and Undo_Clear().

Referenced by CPrefsDlg::OnOK().

00174 {
00175     Undo_Clear();
00176     if (size < 1) g_undoMaxSize = 1;
00177     else g_undoMaxSize = size;
00178 }

Here is the call graph for this function:

void Undo_Start char *  operation  ) 
 

Definition at line 354 of file Undo.cpp.

References Undo_ClearRedo(), and Undo_GeneralStart().

Referenced by Drag_Setup(), Map_ImportBuffer(), CMainFrame::OnBrush3sided(), CMainFrame::OnBrush4sided(), CMainFrame::OnBrush5sided(), CMainFrame::OnBrush6sided(), CMainFrame::OnBrush7sided(), CMainFrame::OnBrush8sided(), CMainFrame::OnBrush9sided(), CMainFrame::OnBrushArbitrarysided(), CMainFrame::OnBrushFlipx(), CMainFrame::OnBrushFlipy(), CMainFrame::OnBrushFlipz(), CMainFrame::OnBrushMakecone(), CMainFrame::OnBrushPrimitivesSphere(), CMainFrame::OnBrushRotatex(), CMainFrame::OnBrushRotatey(), CMainFrame::OnBrushRotatez(), CMainFrame::OnClipSelected(), CMainFrame::OnCurveDeletecolumn(), CMainFrame::OnCurveDeleteFirstcolumn(), CMainFrame::OnCurveDeleteFirstrow(), CMainFrame::OnCurveDeleteLastcolumn(), CMainFrame::OnCurveDeleteLastrow(), CMainFrame::OnCurveDeleterow(), CMainFrame::OnCurveInsertAddcolumn(), CMainFrame::OnCurveInsertAddrow(), CMainFrame::OnCurveInsertcolumn(), CMainFrame::OnCurveInsertInsertcolumn(), CMainFrame::OnCurveInsertInsertrow(), CMainFrame::OnCurveInsertrow(), CMainFrame::OnCurveMoreendcapsbevelsSquarebevel(), CMainFrame::OnCurveMoreendcapsbevelsSquareendcap(), CMainFrame::OnCurvePatchbevel(), CMainFrame::OnCurvePatchcone(), CMainFrame::OnCurvePatchdensetube(), CMainFrame::OnCurvePatchendcap(), CMainFrame::OnCurvePatchsquare(), CMainFrame::OnCurvePatchtube(), CMainFrame::OnCurvePatchverydensetube(), CMainFrame::OnCurveSimplepatchmesh(), CMainFrame::OnCurveThicken(), CMainFrame::OnSelectionArbitraryrotation(), CMainFrame::OnSelectionCsgmerge(), CMainFrame::OnSelectionCsgsubtract(), CMainFrame::OnSelectionDelete(), CMainFrame::OnSelectionMakeDetail(), CMainFrame::OnSelectionMakehollow(), CMainFrame::OnSelectionMakeStructural(), CMainFrame::OnSelectionMovedown(), CMainFrame::OnSelectScale(), CMainFrame::OnSplitSelected(), and Select_SetTexture().

00355 {
00356     Undo_ClearRedo();
00357     Undo_GeneralStart(operation);
00358 }

Here is the call graph for this function:

void Undo_Undo void   ) 
 

Definition at line 569 of file Undo.cpp.

References active_brushes, Brush_AddToList(), Brush_MemorySize(), Brush_RemoveFromList(), brush_t, entity_t::brushes, undo_s::brushlist, undo_s::done, entities, Entity_AddToList(), Entity_Free(), Entity_FreeEpairs(), Entity_LinkBrush(), Entity_MemorySize(), Entity_RemoveFromList(), Entity_UnlinkBrush(), entity_s::entityId, undo_s::entitylist, entity_t::epairs, free(), g_bScreenUpdates, g_lastredo, g_lastundo, g_redoId, g_redolist, g_undoId, g_undolist, g_undoMemorySize, g_undoSize, undo_s::id, malloc(), memset(), bspbrush_s::next, brush_s::next, undo_s::next, NULL, undo_s::operation, brush_s::owner, brush_s::ownerId, brush_s::prev, undo_s::prev, brush_s::redoId, Select_Brush(), Select_Deselect(), selected_brushes, Sys_DoubleTime(), Sys_Printf(), Sys_UpdateWindows(), undo_s::time, undo_t, brush_s::undoId, W_ALL, and world_entity.

Referenced by CMainFrame::OnEditUndo().

00570 {
00571     undo_t *undo, *redo;
00572     brush_t *pBrush, *pNextBrush;
00573     entity_t *pEntity, *pNextEntity, *pUndoEntity;
00574 
00575     if (!g_lastundo)
00576     {
00577         Sys_Printf("Nothing left to undo.\n");
00578         return;
00579     }
00580     if (!g_lastundo->done)
00581     {
00582         Sys_Printf("Undo_Undo: WARNING: last undo not yet finished!\n");
00583     }
00584     // get the last undo
00585     undo = g_lastundo;
00586     if (g_lastundo->prev) g_lastundo->prev->next = NULL;
00587     else g_undolist = NULL;
00588     g_lastundo = g_lastundo->prev;
00589 
00590     //allocate a new redo
00591     redo = (undo_t *) malloc(sizeof(undo_t));
00592     if (!redo) return;
00593     memset(redo, 0, sizeof(undo_t));
00594     redo->brushlist.next = &redo->brushlist;
00595     redo->brushlist.prev = &redo->brushlist;
00596     redo->entitylist.next = &redo->entitylist;
00597     redo->entitylist.prev = &redo->entitylist;
00598     if (g_lastredo) g_lastredo->next = redo;
00599     else g_redolist = redo;
00600     redo->prev = g_lastredo;
00601     redo->next = NULL;
00602     g_lastredo = redo;
00603     redo->time = Sys_DoubleTime();
00604     redo->id = g_redoId++;
00605     redo->done = true;
00606     redo->operation = undo->operation;
00607 
00608     //reset the redo IDs of all brushes using the new ID
00609     for (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush = pBrush->next)
00610     {
00611         if (pBrush->redoId == redo->id)
00612         {
00613             pBrush->redoId = 0;
00614         }
00615     }
00616     for (pBrush = selected_brushes.next; pBrush != NULL && pBrush != &selected_brushes; pBrush = pBrush->next)
00617     {
00618         if (pBrush->redoId == redo->id)
00619         {
00620             pBrush->redoId = 0;
00621         }
00622     }
00623     //reset the redo IDs of all entities using thew new ID
00624     for (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pEntity->next)
00625     {
00626         if (pEntity->redoId == redo->id)
00627         {
00628             pEntity->redoId = 0;
00629         }
00630     }
00631 
00632     // remove current selection
00633     Select_Deselect();
00634     // move "created" brushes to the redo
00635     for (pBrush = active_brushes.next; pBrush != NULL && pBrush != &active_brushes; pBrush=pNextBrush)
00636     {
00637         pNextBrush = pBrush->next;
00638         if (pBrush->undoId == undo->id)
00639         {
00640             //Brush_Free(pBrush);
00641             //move the brush to the redo
00642             Brush_RemoveFromList(pBrush);
00643             Brush_AddToList(pBrush, &redo->brushlist);
00644             //make sure the ID of the owner is stored
00645             pBrush->ownerId = pBrush->owner->entityId;
00646             //unlink the brush from the owner entity
00647             Entity_UnlinkBrush(pBrush);
00648         }
00649     }
00650     // move "created" entities to the redo
00651     for (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)
00652     {
00653         pNextEntity = pEntity->next;
00654         if (pEntity->undoId == undo->id)
00655         {
00656             // check if this entity is in the undo
00657             for (pUndoEntity = undo->entitylist.next; pUndoEntity != NULL && pUndoEntity != &undo->entitylist; pUndoEntity = pUndoEntity->next)
00658             {
00659                 // move brushes to the undo entity
00660                 if (pUndoEntity->entityId == pEntity->entityId)
00661                 {
00662                     pUndoEntity->brushes.next = pEntity->brushes.next;
00663                     pUndoEntity->brushes.prev = pEntity->brushes.prev;
00664                     pEntity->brushes.next = &pEntity->brushes;
00665                     pEntity->brushes.prev = &pEntity->brushes;
00666                 }
00667             }
00668             //
00669             //Entity_Free(pEntity);
00670             //move the entity to the redo
00671             Entity_RemoveFromList(pEntity);
00672             Entity_AddToList(pEntity, &redo->entitylist);
00673         }
00674     }
00675     // add the undo entities back into the entity list
00676     for (pEntity = undo->entitylist.next; pEntity != NULL && pEntity != &undo->entitylist; pEntity = undo->entitylist.next)
00677     {
00678         g_undoMemorySize -= Entity_MemorySize(pEntity);
00679         //if this is the world entity
00680         if (pEntity->entityId == world_entity->entityId)
00681         {
00682             //free the epairs of the world entity
00683             Entity_FreeEpairs(world_entity);
00684             //set back the original epairs
00685             world_entity->epairs = pEntity->epairs;
00686             // unhook the epairs and free the world_entity clone that stored the epairs
00687             pEntity->epairs = NULL;
00688             Entity_Free(pEntity);
00689         }
00690         else
00691         {
00692             Entity_RemoveFromList(pEntity);
00693             Entity_AddToList(pEntity, &entities);
00694             pEntity->redoId = redo->id;
00695         }
00696     }
00697     // add the undo brushes back into the selected brushes
00698     for (pBrush = undo->brushlist.next; pBrush != NULL && pBrush != &undo->brushlist; pBrush = undo->brushlist.next)
00699     {
00700         g_undoMemorySize -= Brush_MemorySize(pBrush);
00701         Brush_RemoveFromList(pBrush);
00702         Brush_AddToList(pBrush, &active_brushes);
00703         for (pEntity = entities.next; pEntity != NULL && pEntity != &entities; pEntity = pNextEntity)
00704         {
00705             if (pEntity->entityId == pBrush->ownerId)
00706             {
00707                 Entity_LinkBrush(pEntity, pBrush);
00708                 break;
00709             }
00710         }
00711         //if the brush is not linked then it should be linked into the world entity
00712         if (pEntity == NULL || pEntity == &entities)
00713         {
00714             Entity_LinkBrush(world_entity, pBrush);
00715         }
00716         //build the brush
00717         //Brush_Build(pBrush);
00718         Select_Brush(pBrush);
00719         pBrush->redoId = redo->id;
00720     }
00721     //
00722     Sys_Printf("%s undone.\n", undo->operation);
00723     // free the undo
00724     g_undoMemorySize -= sizeof(undo_t);
00725     free(undo);
00726     g_undoSize--;
00727     g_undoId--;
00728     if (g_undoId <= 0) g_undoId = 2 * g_undoMaxSize;
00729     //
00730     g_bScreenUpdates = true; 
00731     Sys_UpdateWindows(W_ALL);
00732 }

Here is the call graph for this function:

int Undo_UndoAvailable void   ) 
 

Definition at line 876 of file Undo.cpp.

References undo_s::done, and g_lastundo.

Referenced by CMainFrame::OnUpdateEditUndo().

00877 {
00878     if (g_lastundo)
00879     {
00880         if (g_lastundo->done)
00881             return true;
00882     }
00883     return false;
00884 }


Generated on Thu Aug 25 18:38:12 2005 for Quake III Arena by  doxygen 1.3.9.1