Ludum Dare 29
HackSoc's entry for the Ludum Dare Jam 29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
utils.c File Reference
#include <curses.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "utils.h"
Include dependency graph for utils.c:

Functions

void mvaddprintf (unsigned int y, unsigned int x, const char *fmt,...)
 
char * strdup (const char *str)
 
void mvaddchcol (unsigned int y, unsigned int x, char chr, int fg, int bg, bool bold)
 
const void ** list_choice (bool nochoice, const char *prompt, const char *prompt2, bool multi, bool empty, const char *choices[], const void *results[])
 
const void * random_choice (const void *choices[])
 
void show_help ()
 
void * _xalloc (size_t size)
 
void _xfree (void **ptr)
 

Function Documentation

void* _xalloc ( size_t  size)

Allocate (and zero) memory and immediately bail out if it fails.

Parameters
sizeAmount of memory to allocate (in bytes).
Returns
Allocated memory.
Note
Do not use this directly, use the xalloc macro instead.
void _xfree ( void **  ptr)

Free a non-NULL pointer.

Parameters
ptrPointer to memory to free.
Note
Do not use this directly, use the xfree macro instead.
const void** list_choice ( bool  nochoice,
const char *  prompt,
const char *  prompt2,
bool  multi,
bool  empty,
const char *  choices[],
const void *  results[] 
)

Select from a list of things, berate the player if they enter a bad choice. This clears the screen before and after running.

Parameters
nochoiceThis isn't a choice, just a list.
promptThe initial question.
prompt2The prompt to use after a bad choice.
multiAllow multiple selections.
emptyAllow an empty selection.
choicesNULL-terminated list of choice names.
resultsNULL-terminated list of actual results.
Returns
The results corresponding to the choices, or NULL.

Here is the call graph for this function:

Here is the caller graph for this function:

void mvaddchcol ( unsigned int  y,
unsigned int  x,
char  chr,
int  fg,
int  bg,
bool  bold 
)

Render the given char at the given position with the given colour pair.

Parameters
yThe Y position
xThe X position
chrThe character to render
fgThe foreground colour
bgThe background colour
boldWhether to bold or not

Here is the caller graph for this function:

void mvaddprintf ( unsigned int  y,
unsigned int  x,
const char *  fmt,
  ... 
)

printf the given string at the given position.

Parameters
yy-coordinate of the screen.
xx-coordinate of the screen.
fmtFormat of the string.

Here is the caller graph for this function:

const void* random_choice ( const void *  choices[])

Select a random value from a list

Parameters
choicesNULL-terminates list of choices.

Here is the caller graph for this function:

void show_help ( )

Show some help text to the player.

Here is the call graph for this function:

Here is the caller graph for this function:

char* strdup ( const char *  str)

Duplicate a string

Parameters
strString to duplicate

Here is the caller graph for this function: