Skip to content

Commit 926c42d

Browse files
committed
Including vault descriptions in seed catalog
1 parent f8a9686 commit 926c42d

File tree

10 files changed

+222
-57
lines changed

10 files changed

+222
-57
lines changed

src/brogue/Architect.c

+96-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
#include "GlobalsBase.h"
2626
#include "Globals.h"
2727

28+
static boolean buildAMachineOrChildMachine(enum machineTypes bp,
29+
short originX, short originY,
30+
unsigned long requiredMachineFlags,
31+
item *adoptiveItem,
32+
item *parentSpawnedItems[50],
33+
creature *parentSpawnedMonsters[50],
34+
machineInfo *thisMachineInfoChain);
35+
2836
short topBlobMinX, topBlobMinY, blobWidth, blobHeight;
2937

3038
boolean cellHasTerrainFlag(pos loc, unsigned long flagMask) {
@@ -979,14 +987,84 @@ typedef struct machineData {
979987
short sCols[DCOLS];
980988
} machineData;
981989

990+
machineInfo *createMachineInfo(int level, int id, int type) {
991+
machineInfo *theInfo = (machineInfo *) malloc(sizeof(machineInfo));
992+
memset(theInfo, '\0', sizeof(machineInfo));
993+
994+
machineInfo *theChildInfo = (machineInfo *) malloc(sizeof(machineInfo));
995+
memset(theChildInfo, '\0', sizeof(machineInfo));
996+
997+
theInfo->level = level;
998+
theInfo->type = type;
999+
theInfo->id = id;
1000+
theInfo->childMachineInfo = theChildInfo;
1001+
theInfo->nextMachineInfo = NULL;
1002+
1003+
return theInfo;
1004+
}
1005+
1006+
void deleteAllMachineInfo(machineInfo *theChain) {
1007+
machineInfo *thisMachineInfo, *thisMachineInfo2;
1008+
for (thisMachineInfo = theChain; thisMachineInfo != NULL; thisMachineInfo = thisMachineInfo2) {
1009+
thisMachineInfo2 = thisMachineInfo->nextMachineInfo;
1010+
deleteAllMachineInfo(thisMachineInfo->childMachineInfo);
1011+
free(thisMachineInfo);
1012+
}
1013+
}
1014+
1015+
machineInfo *reverseAllMachineInfo(machineInfo *reverseList) {
1016+
machineInfo *prev = NULL;
1017+
machineInfo *current = reverseList;
1018+
machineInfo *next = NULL;
1019+
1020+
while (current != NULL) {
1021+
next = current->nextMachineInfo;
1022+
current->nextMachineInfo = prev;
1023+
prev = current;
1024+
current = next;
1025+
}
1026+
return prev;
1027+
}
1028+
1029+
void addMachineInfoAndChainToChain(machineInfo *theInfo, machineInfo *theChain) {
1030+
machineInfo *lastMachineInfo = theInfo;
1031+
while (lastMachineInfo->nextMachineInfo != NULL) {
1032+
lastMachineInfo = lastMachineInfo->nextMachineInfo;
1033+
}
1034+
1035+
lastMachineInfo->nextMachineInfo = theChain->nextMachineInfo;
1036+
theChain->nextMachineInfo = theInfo;
1037+
}
1038+
1039+
void addMachineInfoToChain(machineInfo *theInfo, machineInfo *theChain) {
1040+
theInfo->nextMachineInfo = theChain->nextMachineInfo;
1041+
theChain->nextMachineInfo = theInfo;
1042+
}
1043+
1044+
boolean buildAMachine(enum machineTypes bp,
1045+
short originX, short originY,
1046+
unsigned long requiredMachineFlags) {
1047+
machineInfo *tempMachineInfo = createMachineInfo(0, 0, 0);
1048+
if (buildAMachineOrChildMachine(bp, originX, originY, requiredMachineFlags, NULL, NULL, NULL, tempMachineInfo)) {
1049+
// Transfer the valid machineInfo into the main chain and delete the head node
1050+
addMachineInfoToChain(tempMachineInfo->nextMachineInfo, levelMachineInfo);
1051+
tempMachineInfo->nextMachineInfo = NULL;
1052+
free(tempMachineInfo);
1053+
return true;
1054+
}
1055+
deleteAllMachineInfo(tempMachineInfo);
1056+
return false;
1057+
}
1058+
9821059
// Returns true if the machine got built; false if it was aborted.
9831060
// If empty array parentSpawnedItems or parentSpawnedMonsters is given, will pass those back for deletion if necessary.
984-
boolean buildAMachine(enum machineTypes bp,
1061+
static boolean buildAMachineOrChildMachine(enum machineTypes bp,
9851062
short originX, short originY,
9861063
unsigned long requiredMachineFlags,
9871064
item *adoptiveItem,
9881065
item *parentSpawnedItems[MACHINES_BUFFER_LENGTH],
989-
creature *parentSpawnedMonsters[MACHINES_BUFFER_LENGTH]) {
1066+
creature *parentSpawnedMonsters[MACHINES_BUFFER_LENGTH],
1067+
machineInfo *thisMachineInfoChain) {
9901068

9911069
short totalFreq, instance, instanceCount = 0,
9921070
itemCount, monsterCount, qualifyingTileCount,
@@ -1245,6 +1323,10 @@ boolean buildAMachine(enum machineTypes bp,
12451323
}
12461324
}
12471325

1326+
// Store info about created machine (will be deleted if machine fails)
1327+
machineInfo *thisMachineInfo = createMachineInfo(rogue.depthLevel, machineNumber, bp);
1328+
addMachineInfoToChain(thisMachineInfo, thisMachineInfoChain);
1329+
12481330
// DEBUG printf("\n\nWorking on blueprint %i, with origin at (%i, %i). Here's the initial interior map:", bp, originX, originY);
12491331
// DEBUG logBuffer(interior);
12501332

@@ -1548,9 +1630,9 @@ boolean buildAMachine(enum machineTypes bp,
15481630
removeItemFromChain(theItem, floorItems);
15491631
removeItemFromChain(theItem, packItems);
15501632
theItem->nextItem = NULL;
1551-
success = buildAMachine(-1, -1, -1, BP_ADOPT_ITEM, theItem, p->spawnedItemsSub, p->spawnedMonstersSub);
1633+
success = buildAMachineOrChildMachine(-1, -1, -1, BP_ADOPT_ITEM, theItem, p->spawnedItemsSub, p->spawnedMonstersSub, thisMachineInfo->childMachineInfo);
15521634
} else if (feature->flags & MF_BUILD_VESTIBULE) {
1553-
success = buildAMachine(-1, featX, featY, BP_VESTIBULE, NULL, p->spawnedItemsSub, p->spawnedMonstersSub);
1635+
success = buildAMachineOrChildMachine(-1, featX, featY, BP_VESTIBULE, NULL, p->spawnedItemsSub, p->spawnedMonstersSub, thisMachineInfo->childMachineInfo);
15541636
}
15551637

15561638
// Now put the item up for adoption.
@@ -1569,6 +1651,13 @@ boolean buildAMachine(enum machineTypes bp,
15691651
}
15701652
break;
15711653
}
1654+
else {
1655+
// Remove failed machine from info
1656+
deleteAllMachineInfo(thisMachineInfo->childMachineInfo);
1657+
machineInfo *theChildInfo = (machineInfo *) malloc(sizeof(machineInfo));
1658+
memset(theChildInfo, '\0', sizeof(machineInfo));
1659+
thisMachineInfo->childMachineInfo = theChildInfo;
1660+
}
15721661
}
15731662

15741663
if (!i) {
@@ -1737,7 +1826,7 @@ static void addMachines() {
17371826
// Add the amulet holder if it's depth 26:
17381827
if (rogue.depthLevel == gameConst->amuletLevel) {
17391828
for (failsafe = 50; failsafe; failsafe--) {
1740-
if (buildAMachine(MT_AMULET_AREA, -1, -1, 0, NULL, NULL, NULL)) {
1829+
if (buildAMachine(MT_AMULET_AREA, -1, -1, 0)) {
17411830
break;
17421831
}
17431832
}
@@ -1757,7 +1846,7 @@ static void addMachines() {
17571846
}
17581847

17591848
for (failsafe = 50; machineCount && failsafe; failsafe--) {
1760-
if (buildAMachine(-1, -1, -1, BP_REWARD, NULL, NULL, NULL)) {
1849+
if (buildAMachine(-1, -1, -1, BP_REWARD)) {
17611850
machineCount--;
17621851
rogue.rewardRoomsGenerated++;
17631852
}
@@ -1835,7 +1924,7 @@ static void runAutogenerators(boolean buildAreaMachines) {
18351924
// Attempt to build the machine if requested.
18361925
// Machines will find their own locations, so it will not be at the same place as terrain and DF.
18371926
if (gen->machine > 0) {
1838-
buildAMachine(gen->machine, -1, -1, 0, NULL, NULL, NULL);
1927+
buildAMachine(gen->machine, -1, -1, 0);
18391928
}
18401929
}
18411930
}

src/brogue/GlobalsBase.c

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ creatureList purgatory; // used to hold dead allies awaiting resurrection
4949
item *floorItems;
5050
item *packItems;
5151
item *monsterItemsHopper;
52+
machineInfo *allMachineInfo;
53+
machineInfo *levelMachineInfo;
5254

5355
char displayedMessage[MESSAGE_LINES][COLS*2];
5456
short messagesUnconfirmed;

src/brogue/GlobalsBase.h

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ extern creatureList purgatory;
6565
extern item *floorItems;
6666
extern item *packItems;
6767
extern item *monsterItemsHopper;
68+
extern machineInfo *allMachineInfo;
69+
extern machineInfo *levelMachineInfo;
6870
extern short numberOfWaypoints;
6971

7072
extern char displayedMessage[MESSAGE_LINES][COLS*2];

src/brogue/Monsters.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ creature *spawnHorde(short hordeID, pos loc, unsigned long forbiddenFlags, unsig
851851

852852
if (theHorde->machine > 0) {
853853
// Build the accompanying machine (e.g. a goblin encampment)
854-
buildAMachine(theHorde->machine, loc.x, loc.y, 0, NULL, NULL, NULL);
854+
buildAMachine(theHorde->machine, loc.x, loc.y, 0);
855855
}
856856

857857
leader = generateMonster(theHorde->leaderType, true, true);

src/brogue/Rogue.h

+17-6
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,15 @@ typedef struct keyLocationProfile {
13921392
boolean disposableHere;
13931393
} keyLocationProfile;
13941394

1395+
typedef struct machineInfo {
1396+
int type;
1397+
int level;
1398+
int id;
1399+
// Child machines are deleted when the parent is deleted, so should only be in the childMachineInfo chain
1400+
struct machineInfo *childMachineInfo;
1401+
struct machineInfo *nextMachineInfo;
1402+
} machineInfo;
1403+
13951404
typedef struct item {
13961405
unsigned short category;
13971406
short kind;
@@ -2376,7 +2385,6 @@ typedef struct gameConstants {
23762385
const int amuletLevel; // level on which the amulet appears (used in signed arithmetic)
23772386

23782387
const int depthAccelerator; // factor for how fast depth-dependent features scale compared to usual 26-level dungeon
2379-
const int minimumAltarLevel; // how deep before resurrection and commutation altars can be generated
23802388
const int minimumLavaLevel; // how deep before lava can be generated
23812389
const int minimumBrimstoneLevel; // how deep before brimstone can be generated
23822390
const int mutationsOccurAboveLevel; // how deep before monster mutations can be generated
@@ -2901,11 +2909,10 @@ extern "C" {
29012909
void analyzeMap(boolean calculateChokeMap);
29022910
boolean buildAMachine(enum machineTypes bp,
29032911
short originX, short originY,
2904-
unsigned long requiredMachineFlags,
2905-
item *adoptiveItem,
2906-
item *parentSpawnedItems[MACHINES_BUFFER_LENGTH],
2907-
creature *parentSpawnedMonsters[MACHINES_BUFFER_LENGTH]);
2912+
unsigned long requiredMachineFlags);
29082913
void attachRooms(short **grid, const dungeonProfile *theDP, short attempts, short maxRoomCount);
2914+
machineInfo *createMachineInfo(int level, int id, int type);
2915+
void deleteAllMachineInfo(machineInfo *theChain);
29092916
void digDungeon(void);
29102917
void updateMapToShore(void);
29112918
short levelIsDisconnectedWithBlockingMap(char blockingMap[DCOLS][DROWS], boolean countRegionSize);
@@ -3496,7 +3503,7 @@ extern "C" {
34963503
int quitImmediately(void);
34973504
void dialogAlert(char *message);
34983505
void mainBrogueJunction(void);
3499-
int printSeedCatalog(uint64_t startingSeed, uint64_t numberOfSeedsToScan, unsigned int scanThroughDepth, boolean isCsvFormat, char *errorMessage);
3506+
int printSeedCatalog(uint64_t startingSeed, uint64_t numberOfSeedsToScan, unsigned int scanThroughDepth, boolean isCsvFormat, boolean includeVaults, char *errorMessage);
35003507

35013508
void initializeButton(brogueButton *button);
35023509
void drawButtonsInState(buttonState *state, screenDisplayBuffer *button_dbuf);
@@ -3519,6 +3526,10 @@ extern "C" {
35193526
rogueEvent *returnEvent);
35203527

35213528
void dijkstraScan(short **distanceMap, short **costMap, boolean useDiagonals);
3529+
void deleteAllMachineInfo(machineInfo *theChain);
3530+
void addMachineInfoAndChainToChain(machineInfo *theInfo, machineInfo *theChain);
3531+
void addMachineInfoToChain(machineInfo *theInfo, machineInfo *theChain);
3532+
machineInfo *reverseAllMachineInfo(machineInfo *reverseList);
35223533

35233534
#if defined __cplusplus
35243535
}

src/brogue/RogueMain.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ void initializeRogue(uint64_t seed) {
331331
memset(monsterItemsHopper, '\0', sizeof(item));
332332
monsterItemsHopper->nextItem = NULL;
333333

334+
allMachineInfo = createMachineInfo(0, 0, 0);
335+
334336
for (i = 0; i < MAX_ITEMS_IN_MONSTER_ITEMS_HOPPER; i++) {
335337
theItem = generateItem(ALL_ITEMS & ~FOOD, -1); // Monsters can't carry food: the food clock cannot be cheated!
336338
theItem->nextItem = monsterItemsHopper->nextItem;
@@ -687,6 +689,9 @@ void startLevel(short oldLevelNumber, short stairDirection) {
687689

688690
levels[rogue.depthLevel-1].items = NULL;
689691

692+
// Initialize a chain for the level only
693+
levelMachineInfo = createMachineInfo(0, 0, 0);
694+
690695
pos upStairLocation;
691696
int failsafe;
692697
for (failsafe = 50; failsafe; failsafe--) {
@@ -730,6 +735,15 @@ void startLevel(short oldLevelNumber, short stairDirection) {
730735
}
731736
}
732737

738+
machineInfo *firstRealNode = levelMachineInfo->nextMachineInfo;
739+
levelMachineInfo->nextMachineInfo = NULL;
740+
free(levelMachineInfo);
741+
742+
if (firstRealNode != NULL) {
743+
machineInfo *reversed = reverseAllMachineInfo(firstRealNode);
744+
addMachineInfoAndChainToChain(reversed, allMachineInfo);
745+
}
746+
733747
// re-seed the RNG
734748
seedRandomGenerator(oldSeed);
735749

@@ -863,7 +877,7 @@ void startLevel(short oldLevelNumber, short stairDirection) {
863877
if (itemAtLoc(player.loc)) {
864878
item *theItem = itemAtLoc(player.loc);
865879
char msg[COLS * 3], itemDescription[COLS * 3] = "";
866-
880+
867881
// the message pane wraps so we don't need to limit the description
868882
describedItemName(theItem, itemDescription, COLS * 3);
869883
sprintf(msg, "Below you lies %s.", itemDescription);
@@ -955,7 +969,7 @@ static void removeDeadMonstersFromList(creatureList *list) {
955969
removeCreature(list, decedent);
956970
if (decedent->leader == &player
957971
&& !(decedent->bookkeepingFlags & MB_DOES_NOT_RESURRECT)
958-
&& (!(decedent->info.flags & MONST_INANIMATE)
972+
&& (!(decedent->info.flags & MONST_INANIMATE)
959973
|| (monsterCatalog[decedent->info.monsterID].abilityFlags & MA_ENTER_SUMMONS))
960974
&& (decedent->bookkeepingFlags & MB_WEAPON_AUTO_ID)
961975
&& !(decedent->bookkeepingFlags & MB_ADMINISTRATIVE_DEATH)) {
@@ -1027,6 +1041,8 @@ void freeEverything() {
10271041
freeGrid(rogue.wpDistance[i]);
10281042
}
10291043

1044+
deleteAllMachineInfo(allMachineInfo);
1045+
10301046
deleteAllFlares();
10311047
if (rogue.flares) {
10321048
free(rogue.flares);
@@ -1218,7 +1234,7 @@ void victory(boolean superVictory) {
12181234
unsigned long totalValue = 0;
12191235
rogueHighScoresEntry theEntry;
12201236
boolean qualified, isPlayback;
1221-
1237+
12221238
char recordingFilename[BROGUE_FILENAME_MAX] = {0};
12231239

12241240
rogue.gameInProgress = false;

0 commit comments

Comments
 (0)