2011-06-15 08:34:28 -04:00
|
|
|
/************************************************************************
|
|
|
|
* *
|
|
|
|
* Star Traders: A Game of Interstellar Trading *
|
|
|
|
* Copyright (C) 1990-2011, John Zaitseff *
|
|
|
|
* *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Author: John Zaitseff <J.Zaitseff@zap.org.au>
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
This file, utils.h, contains various utility function declarations for
|
|
|
|
Star Traders.
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef included_UTILS_H
|
|
|
|
#define included_UTILS_H 1
|
|
|
|
|
|
|
|
|
2011-06-30 01:25:30 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Constants and type declarations *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#define GAME_FILENAME_PROTO "game%d"
|
|
|
|
#define GAME_FILENAME_BUFSIZE (16)
|
|
|
|
|
|
|
|
|
2011-07-10 20:31:19 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Utility macro definitions *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// Type-unsafe minimum and maximum macros
|
|
|
|
|
|
|
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
|
|
|
|
2011-06-15 08:34:28 -04:00
|
|
|
/************************************************************************
|
|
|
|
* Utility function declarations *
|
|
|
|
************************************************************************/
|
|
|
|
|
2011-07-04 03:13:29 -04:00
|
|
|
// Initialisation and environment functions
|
|
|
|
|
2011-06-15 08:34:28 -04:00
|
|
|
extern void init_program_name (char *argv[]);
|
|
|
|
extern const char *program_name (void);
|
|
|
|
|
|
|
|
extern const char *home_directory (void);
|
|
|
|
extern const char *data_directory (void);
|
|
|
|
|
2011-07-03 20:28:50 -04:00
|
|
|
extern char *game_filename (const int game_num);
|
2011-06-30 01:25:30 -04:00
|
|
|
|
2011-07-04 03:13:29 -04:00
|
|
|
// Error-reporting functions
|
|
|
|
|
2011-07-02 00:23:35 -04:00
|
|
|
extern void err_exit (const char *format, ...)
|
|
|
|
__attribute__((noreturn, format (printf, 1, 2)));
|
|
|
|
extern void errno_exit (const char *format, ...)
|
|
|
|
__attribute__((noreturn, format (printf, 1, 2)));
|
|
|
|
|
2011-07-04 03:13:29 -04:00
|
|
|
// Random number functions
|
|
|
|
|
|
|
|
extern void init_rand (void);
|
|
|
|
extern double randf (void);
|
|
|
|
extern int randi (int limit);
|
|
|
|
|
2011-06-15 08:34:28 -04:00
|
|
|
|
|
|
|
#endif /* included_UTILS_H */
|