MCPcopy Create free account
hub / github.com/TurningWheel/Barony / undo

Function undo

src/editor.cpp:1188–1227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1186-------------------------------------------------------------------------------*/
1187
1188void undo()
1189{
1190 node_t* node;
1191 if ( undospot == NULL )
1192 {
1193 return;
1194 }
1195 selectedEntity[0] = NULL;
1196 if ( undospot == undolist.last )
1197 {
1198 node_t* tempnode = undospot;
1199 makeUndo();
1200 undospot = tempnode;
1201 }
1202 free(map.tiles);
1203 free(camera.vismap);
1204 map_t* undomap = (map_t*)undospot->element;
1205 map.width = undomap->width;
1206 map.height = undomap->height;
1207 map.tiles = (Sint32*) malloc(sizeof(Sint32) * map.width * map.height * MAPLAYERS);
1208 camera.vismap = (bool*) malloc(sizeof(bool) * map.height * map.width);
1209 memset(camera.vismap, 0, sizeof(bool) * map.height * map.width);
1210 memcpy(map.tiles, undomap->tiles, sizeof(Sint32)*undomap->width * undomap->height * MAPLAYERS);
1211 list_FreeAll(map.entities);
1212 for ( node = undomap->entities->first; node != NULL; node = node->next )
1213 {
1214 Entity* entity = newEntity(((Entity*)node->element)->sprite, 1, map.entities, nullptr);
1215
1216 setSpriteAttributes(entity, (Entity*)node->element, (Entity*)node->element);
1217 }
1218 if ( redospot != NULL )
1219 {
1220 redospot = redospot->prev;
1221 }
1222 else
1223 {
1224 redospot = undospot->next;
1225 }
1226 undospot = undospot->prev;
1227}
1228
1229void redo()
1230{

Callers 1

buttonUndoFunction · 0.85

Calls 4

makeUndoFunction · 0.85
list_FreeAllFunction · 0.85
newEntityFunction · 0.85
setSpriteAttributesFunction · 0.85

Tested by

no test coverage detected