-
Notifications
You must be signed in to change notification settings - Fork 0
Code Map
This page serves as a "map" of all of the files in the src directory. This page should be helpful to new contributors and is intended to help demystify them as to the structure of the code or where to find what they're looking for.
What follows is a sorted list of the files in the src directory grouped by the file's purpose and function. Note that some files may be in more than one group.
- color.d
- config.d
- fonts.d
- global.d
- iflags.d
- inven.d
- item.d
- mapgen.d
- moves.d
- msg.d
- savefile.d
- tflags.d
- tile.d
- tsyms.d
What follows is a list of every file in the src directory and a brief
summary of the file's intended purpose and general content. The files are
organized in alphabetical order.
Defines flags which are used to determine whether certain "cheat modes" have been activated. This file is also used to determine whether or not the game is going to start with a test map rather than generating a normal dungeon.
Defines a class for representing in-game color data and a second for
storing color pairs, each of which is used to determine what colors the
user interface will use to represent any particular character.
Defines standard colors pairs and an enum used to represent them in
the Symbol struct defined in sym.d. Also defines a function
init_colors which is used to initialize the standard set of color
pairs and store them in a global array CLR which is used by the game's
output functions.
Defines various flags used to configure the game at compile-time.
Sets up the random number generator, Lucky; and defines structs and
functions related to in-game dice rolls.
Defines a struct FontDef which is used by the SDL interfaces to store
data for specific fonts, namely the path to a font file and the height and
width of each tile which uses that font.
Also defines an enum TileSet which is used to store the three primary
fonts used by the game and identify them by name, currently standard,
bold, and dyslexic.
Defines functions related to calculating field-of-vision in-game.
Note that the code in this file is derived from the libtcod source code and as such is protected by the libtcod license in addition to the SwashRL license.
The global import file for SwashRL.
Defines a lot of important flags for the game's function, including the name of the compiled game and the version number, sets up a number of global variables determining functions such as map size and drawing offsets, and sets flags informing the program of which user interfaces are being compiled.
This file also imports every other source code file in the correct order.
Defines flags used to determine item properties, such as equipment slot and inventory category.
Sets up the inventory system by defining the Inven struct, the indexes of
the various inventory slots in the items array, and functions used for
checking if the player character has a free grasp, whether an item can be
equipped in a particular slot, etcetera.
Defines the CursesIO class, which contains functions used for input and
output on the curses interface. This class will define basic input and
output functions used in the SwashIO interface in iomain.d to
create more complex behaviors related to basic game IO.
Defines the SwashIO interface, which serves as a template for input and
output on the curses and SDL interfaces and uses the generic functions defined
by those interfaces to set up complex input and output behaviors such as
displaying maps, printing characters and lines of text, and managing the
inventory and equipment screens.
This file will also import iocurses.d and ioterm.d
depending on what configuration is being compiled (i.e. whether version is
curses, sdl, or both)
Defines the SDLTerminalIO class, which contains functions and objects used
for interfacing with the SDL "virtual terminal" interface. This class will
set up the SDL window and initialize fonts, and defines functions which
convert color flags to SDL color structs. This class also contains
functions which allow for an "emergency shutdown" of the SDL window in case of
the user getting stuck in an input loop and defines basic input and output
functions which are used by the SwashIO interface in iomain.d
to create more complex behaviors.
Also defined in this file is the SDLException, which is used to provide
error-handling behavior for the SDL interface.
Note that large portions of the code in this file are protected by the SmugglerRL license in addition to the SwashRL license.
Defines the Item struct, a placeholder No_item used to fill in empty
inventory and equipment slots as well as empty item slots on floor tiles,
and a function Item_here used to determine whether or not an item slot is
empty.
Defines a function used to create keymaps, associative arrays or hash maps which are used to match the result of keypresses with movement flags defined in moves.d.
Also defined in this file is InvalidKeymapException, an Exception used to
provide error information about bad keymaps created using the keymap
function.
The mainfile for the program.
Defines functions related to displaying the version number, greeting the
player at startup, initial game setup, and the main game loop. Also defines
the SDL_MODES enum used to determine whether the SDL "mode" being used is
terminal, full, or none.
The main function does a lot of the inital setup for the game, including
interpreting command-line parameters, activating cheat modes, handling map
storage, and most of the other essential functions which are necessary for
setting up the game. It is also the main function which handles abrupt
program shutdowns such as the closure of the SDL window.
The mainloop in main also handles user input, checking for messages at the
end of every turn, and interpreting user input by either directly addressing
movement flags or passing them into the umove function from mov.d.
Defines the Room and Map structs used to hold level data, including
tile data, the locations of items, monster storage, the visibility of each
tile, and the coordinates for the player's starting location.
Also defined in this file are functions used to add and remove monsters from the map.
Contains functions used to generate new Maps using various algorithms,
including an empty_Map. In future revisions of the code, the
generate_new_map function will take in a parameter determining which level
generation algorithm will be used.
Contains functions and constants used by the functions in mapalgo.d to generate maps by carving rooms and corridors, growing mold in the level, et cetera.
This file also contains the test_map function, which in debug builds can be
used to generate the test map.
Defines the Monst struct, which is used to represent monster data, and
functions used to create new monsters.
Also defined in this file are the functions monst_name, the_monst, and
The_monst, which are used to format a monster's name into formatted strings
such as "%s hits you!"
Also defined in this file is the Mon struct, which in future versions of
the code will be used to store monster generation data from which Monst
objects can be generated.
Contains all functions related to player and monster movement, including functions which calculate changes in x and y coordinate based on movement data and monster AI.
Contains flags which define all of the possible "moves" the player can make, or in other words all of the possible commands which can be given to the game. Some of these are also used in mov.d to calculate differences in x and y coordinate during movement.
Stores the message buffer and message history and functions used to manipulate them.
Defines all of the functions and other information related to saving and loading from files. This file also handles file I/O exceptions and determines the compatibility of save files from previous versions of the game.
An explanation of the save file format can be found on this wiki.
Defines the Symbol struct, which stores data on symbols which are
displayed in the game's output, and the symdata function used to define
Symbols.
In a previous life, this file was used to determine which system the program was being compiled for, but now it just outputs compile-time messages related to what system it is being compiled for and which interfaces are being included.
Defines flags used to determine special properties about map tiles.
Defines the Tile struct, which is used to store map tile data, and the
Terrain enum which stories standard map tiles.
Defines Symbols for standard map tiles.
Defines miscellaneous minor "utility functions" which don't fit anywhere else in the source code.
Defines functions which initialize the player character and determine whether
or not a given monster is in fact the player. Also aliases Player to the
Monst struct defined in monst.d