@@ -539,6 +539,51 @@ static void updateColors() {
539
539
}
540
540
}
541
541
542
+ static machineInfo * reverseAllMachineInfo2 () {
543
+ machineInfo * prev = NULL ;
544
+ machineInfo * current = allMachineInfo ;
545
+ machineInfo * next = NULL ;
546
+
547
+ while (current != NULL ) {
548
+ next = current -> nextMachineInfo ;
549
+ current -> nextMachineInfo = prev ;
550
+ prev = current ;
551
+ current = next ;
552
+ }
553
+ return prev ;
554
+ }
555
+
556
+ static void deleteMachineInfo2 (machineInfo * machineInfo ) {
557
+ free (machineInfo );
558
+ }
559
+
560
+ static void deleteAllMachineInfo2 (machineInfo * theChain ) {
561
+ machineInfo * thisMachineInfo , * thisMachineInfo2 ;
562
+ for (thisMachineInfo = theChain ; thisMachineInfo != NULL ; thisMachineInfo = thisMachineInfo2 ) {
563
+ thisMachineInfo2 = thisMachineInfo -> nextMachineInfo ;
564
+ deleteAllMachineInfo2 (thisMachineInfo -> childMachineInfo );
565
+ deleteMachineInfo2 (thisMachineInfo );
566
+ }
567
+ }
568
+
569
+ static void addMachineInfoToChain2 (machineInfo * theInfo , machineInfo * theChain ) {
570
+ theInfo -> nextMachineInfo = theChain -> nextMachineInfo ;
571
+ theChain -> nextMachineInfo = theInfo ;
572
+ }
573
+
574
+ static void addMachineInfoAndChainToChain (machineInfo * theInfo , machineInfo * theChain ) {
575
+ //find last machineInfo nextMachineInfo from theInfo
576
+
577
+ machineInfo * lastMachineInfo = theInfo ;
578
+ while (lastMachineInfo -> nextMachineInfo != NULL ) {
579
+ lastMachineInfo = lastMachineInfo -> nextMachineInfo ;
580
+ }
581
+
582
+ lastMachineInfo -> nextMachineInfo = theChain -> nextMachineInfo ;
583
+ theChain -> nextMachineInfo = theInfo ;
584
+ }
585
+
586
+
542
587
void startLevel (short oldLevelNumber , short stairDirection ) {
543
588
uint64_t oldSeed ;
544
589
item * theItem ;
@@ -686,6 +731,9 @@ void startLevel(short oldLevelNumber, short stairDirection) {
686
731
687
732
levels [rogue .depthLevel - 1 ].items = NULL ;
688
733
734
+ // Initialize a chain for the level only
735
+ levelMachineInfo = createMachineInfo (0 , 0 , 0 );
736
+
689
737
pos upStairLocation ;
690
738
int failsafe ;
691
739
for (failsafe = 50 ; failsafe ; failsafe -- ) {
@@ -729,6 +777,13 @@ void startLevel(short oldLevelNumber, short stairDirection) {
729
777
}
730
778
}
731
779
780
+ machineInfo * firstRealNode = levelMachineInfo -> nextMachineInfo ;
781
+ levelMachineInfo -> nextMachineInfo = NULL ;
782
+ deleteAllMachineInfo2 (levelMachineInfo );
783
+
784
+ //machineInfo *reversed = reverseAllMachineInfo2(firstRealNode);
785
+ addMachineInfoAndChainToChain (firstRealNode , allMachineInfo );
786
+
732
787
// re-seed the RNG
733
788
seedRandomGenerator (oldSeed );
734
789
0 commit comments