1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-12-04 14:46:45 -05:00
Commit Graph

289 Commits

Author SHA1 Message Date
John Zaitseff
46c7a55203 Remove LINE_OFFSET and COL_OFFSET; rename COL_CENTER to WCENTER 2011-07-20 15:53:53 +10:00
John Zaitseff
cbff5193d9 Include microseconds as well as seconds for the random number seed 2011-07-20 12:42:10 +10:00
John Zaitseff
f5ca777b37 Ignore character returned by wgetch() in wait_for_key() 2011-07-20 12:00:21 +10:00
John Zaitseff
c6007be5aa Move background setting and box drawing into newtxwin()
Setting the background and drawing a box is almost always the first thing
done after window creation.
2011-07-20 11:41:46 +10:00
John Zaitseff
ee259b8a83 Add a few more function comments 2011-07-20 10:50:18 +10:00
John Zaitseff
da7477dc28 Compensate for the POSIX locale not having a currency symbol
The function l_strfmon() will insert MOD_POSIX_CURRENCY_SYMBOL in the
appropriate place when used with the POSIX ("C") locale.
2011-07-20 10:44:44 +10:00
John Zaitseff
e56247b1b4 Bug fix: company share prices CAN be zero, if company does not exist 2011-07-19 23:31:20 +10:00
John Zaitseff
ee37b4d210 Add the --no-encrypt command-line option 2011-07-19 23:24:17 +10:00
John Zaitseff
cdb98dbedb Make slight corrections to the help text 2011-07-19 23:19:08 +10:00
John Zaitseff
d47848850f Clean up help.c and help.h: remove superfluous lines, add comments 2011-07-19 23:07:26 +10:00
John Zaitseff
b10b4c21ed Clean up the system.h header file 2011-07-19 22:53:06 +10:00
John Zaitseff
fdd53e94ba Add an "end of file" comment 2011-07-19 22:30:26 +10:00
John Zaitseff
e7208c72db Implement the --max-turn command line option 2011-07-19 22:29:36 +10:00
John Zaitseff
fe65657eda Move function comments to start of file; remove unneeded parentheses 2011-07-19 22:07:15 +10:00
John Zaitseff
8725983d94 Update header comments 2011-07-19 21:47:19 +10:00
John Zaitseff
c3d265a9ff Clean up utils.c and utils.h
Move all function interface comments to the header file (where they
should have been in the first place), remove superfluous parentheses
where allowed by the precedence of C operators.
2011-07-19 21:38:27 +10:00
John Zaitseff
c19feab652 Clean up various comments, etc, in header files 2011-07-19 20:32:00 +10:00
John Zaitseff
13c6353dd2 Replace all visible mentions of <ESC> with <CTRL><C>
Note that pressing <ESC> will often generate up to one second's worth of
delay, whereas <CTRL><C> causes no delay.
2011-07-19 19:45:42 +10:00
John Zaitseff
fcffaa5860 Add checks for KEY_EXIT: same functionality as pressing CTRL-C 2011-07-19 19:22:20 +10:00
John Zaitseff
ccbe7405f8 Replace "out of memory" errors with calls to err_exit_nomem() 2011-07-19 19:16:34 +10:00
John Zaitseff
7bfdcff969 Minor (cosmetic) changes to the ordering of elements in some files 2011-07-19 19:09:59 +10:00
John Zaitseff
04879e376e Replace obsoleted vwprintw() with vw_printw() 2011-07-19 15:36:22 +10:00
John Zaitseff
8165785fc0 Handle rounding of input amounts a little better 2011-07-19 15:04:39 +10:00
John Zaitseff
5e15e2a197 Bug fix: only remove thousands separators if present in the locale 2011-07-19 14:54:38 +10:00
John Zaitseff
ef83258e2b Make file saving and loading locale-independent for numbers 2011-07-19 14:47:18 +10:00
John Zaitseff
7eafa205e7 Minor bug fix: the done variable must be initialised before use 2011-07-19 14:36:00 +10:00
John Zaitseff
625f265108 Allow the player to buy and sell shares
This function, trade_shares(), is the last function needed for Star
Traders: the game is now complete.

The current line count is 6667 lines of C code (src/*.[ch]), as compared
with 1657 lines in the CP/M-80 version, 1674 lines in CP/M-86, 4266 lines
in DOS (2225 in the main program) and 4580 lines in Windows 16-bit.
2011-07-19 14:21:32 +10:00
John Zaitseff
dc14a0e633 Implement the gettxlong() function to input an integer 2011-07-19 14:15:33 +10:00
John Zaitseff
26436c08dd Rearrange the Stock Exchange display
The Stock Exchange display now mimics the Stock Portfolio page a little
more.  Also allow more keys to exit parts of the Stock Exchange.
2011-07-19 11:10:09 +10:00
John Zaitseff
e38c151752 Implement the visit_bank() function 2011-07-19 00:38:06 +10:00
John Zaitseff
8b504b645d Implement the gettxdouble() function to input a floating point number 2011-07-19 00:37:10 +10:00
John Zaitseff
c3097e7f6f Fix a long-standing bug: don't impound more cash than the debt amount! 2011-07-19 00:03:34 +10:00
John Zaitseff
937fea4ccb Make company letters stand out more on the map in --no-color mode 2011-07-18 20:55:47 +10:00
John Zaitseff
ccd451cf5c Implement the main part of exchange_stock() 2011-07-18 20:16:55 +10:00
John Zaitseff
c686d2f548 Rename sel_val_t to selection_t; add values useful for exchange_stock() 2011-07-18 20:16:24 +10:00
John Zaitseff
84b4972f93 Remove a superfluous call to wrefresh() in show_map() 2011-07-18 17:21:54 +10:00
John Zaitseff
1beb2003ef Remove the global variables selection, credit_limit and bid_used 2011-07-18 16:22:24 +10:00
John Zaitseff
c123a87cc3 Move common bankruptcy code to a separate function, bankrupt_player() 2011-07-18 15:34:57 +10:00
John Zaitseff
2ec1c7faa9 Check if a player's debt is too large 2011-07-18 15:03:07 +10:00
John Zaitseff
5fca151b60 Add the function adjust_values() 2011-07-18 14:05:22 +10:00
John Zaitseff
4ecb40fe27 Complete the implementation of the process_move() function
This includes the functions try_start_new_company(), merge_companies(),
include_outpost() and inc_share_price().
2011-07-16 19:23:12 +10:00
John Zaitseff
c182f9df6f Increase the size of Game Winner window at the end of the game 2011-07-16 19:20:50 +10:00
John Zaitseff
a75ec7479d Add center3(): centre three strings 2011-07-16 15:47:05 +10:00
John Zaitseff
885b49f19d Allow a player to declare themselves bankrupt 2011-07-16 14:37:29 +10:00
John Zaitseff
e2dbe549b2 Implement the "Save game" player choice; start coding process_move() 2011-07-16 13:34:13 +10:00
John Zaitseff
6c708d6f83 Add more control keys handled by various input routines for consistency 2011-07-16 13:32:02 +10:00
John Zaitseff
2c65c5be4a Move the stock exchange and bank functions (to be written) to exch.c 2011-07-16 10:43:19 +10:00
John Zaitseff
ddb214c5fb Move the selection and processing of game moves to move.c 2011-07-16 10:30:58 +10:00
John Zaitseff
eb2fe45beb Reorganise the information in src/README 2011-07-16 10:10:36 +10:00
John Zaitseff
dd40b94301 Move game_load() and game_save() functions to their own source file 2011-07-16 09:58:53 +10:00
John Zaitseff
36c9a57db0 Implement the end_game() function: display the winner of the game 2011-07-15 23:37:56 +10:00
John Zaitseff
f24eead880 Make window titles to be consistently title-cased 2011-07-15 21:57:23 +10:00
John Zaitseff
dec1a44caf Add key presses to show_help() and get_move() to be more consistent 2011-07-15 21:45:23 +10:00
John Zaitseff
b39a1a7567 Redefine CURS_ON to be CURS_NORMAL as this works better with xterm
If "-bc" (flash cursor) is passed to xterm, CURS_VISIBLE will stop it
from flashing--not the intended effect.  CURS_NORMAL will continue to
make the cursor flash with the "-bc" option.
2011-07-15 21:35:51 +10:00
John Zaitseff
97a9c6a35b Shorten the enumeration names for the selection global variable 2011-07-15 21:32:37 +10:00
John Zaitseff
e06f48070f Move the closing of two windows to process_move() 2011-07-15 21:15:44 +10:00
John Zaitseff
0a63e1ca1e Implement the next_player() function 2011-07-15 21:13:32 +10:00
John Zaitseff
0d4f7cc226 Implement the get_move() function 2011-07-15 20:54:40 +10:00
John Zaitseff
6a55745d5d Bug fix: total worth CAN be negative! 2011-07-15 19:08:43 +10:00
John Zaitseff
04513c9d30 Make the load_game and save_game macros more reliable
These macros now follow recommended practices as used by the Linux
kernel: in particular, by using the "do { ... } while (0)" construct.
2011-07-15 18:56:33 +10:00
John Zaitseff
5c28cea858 Move the BUFSIZE macro to trader.h; remove the similar GAME_BUFSIZE 2011-07-15 18:52:31 +10:00
John Zaitseff
4cca36441a Implement the show_status() and total_value() functions 2011-07-15 17:46:57 +10:00
John Zaitseff
717fc28339 Generate the map title line in a string-independent fashion 2011-07-15 14:58:32 +10:00
John Zaitseff
34c787cc30 Correct some bugs in center(); add the center2() function 2011-07-15 14:55:56 +10:00
John Zaitseff
d9d703f48e Conditionally wait for the user and close the window before returning 2011-07-15 12:21:59 +10:00
John Zaitseff
ab9a9359e2 Implement the show_map() function that displays the galaxy map 2011-07-15 11:19:14 +10:00
John Zaitseff
e46c45d52e Implement the select_moves() function
This function select random moves for the current player.
2011-07-14 21:44:18 +10:00
John Zaitseff
546c80053f Add the --no-color (and --no-colour) command-line options 2011-07-14 20:19:04 +10:00
John Zaitseff
3093e2cfd3 Add the help text, including all appropriate formatting 2011-07-14 19:27:57 +10:00
John Zaitseff
92a95b253f Implement the show_help() function with sample text 2011-07-14 16:29:29 +10:00
John Zaitseff
09d4455c3e Add window attributes for the galaxy map 2011-07-14 15:16:04 +10:00
John Zaitseff
39d6bc5b37 Add the abort_game global variable
The abort_game variable allows the program to abort the game without
showing the final winner.
2011-07-14 15:11:53 +10:00
John Zaitseff
200f7cdf97 Revise the scramble() and unscramble() functions
The scramble() and unscramble() functions now use a moving (incrementing)
key for the XOR encryption/decryption.  Also include a table of XOR keys
to use at random for encryption.
Revised the scramble() and unscramble() functions to use a moving
(incrementing) key for the XOR encryption/decryption.  Also generated a
table of XOR keys to use at random for encryption.
2011-07-14 12:30:23 +10:00
John Zaitseff
91d77f002c Bug fix: resolve memory leakage for the filename variable 2011-07-13 18:18:02 +10:00
John Zaitseff
593cda9a97 Add to the save_game() function to save the current game to disk 2011-07-13 12:52:38 +10:00
John Zaitseff
0b9b60780d Bug fix: actually copy the string read in to the destination buffer 2011-07-13 12:51:25 +10:00
John Zaitseff
3f96e587aa Rearrange the order of some global variables
Rearrange some global variables for consistency with initialisation in
init_game() and load_game().
2011-07-11 23:25:13 +10:00
John Zaitseff
1c502d671c Load a game file; support (trivial) game file encryption 2011-07-11 23:23:21 +10:00
John Zaitseff
16c421574f Add the scramble() and unscramble() functions
These functions provide simple encryption and decryption to thwart casual
cheating!
2011-07-11 23:21:10 +10:00
John Zaitseff
c5eda1eaab Add code to the load_game() function
The load_game() function now checks for errors while opening the game
file.
2011-07-11 18:07:51 +10:00
John Zaitseff
89c3512a1b Modify the wait_for_key() routine to take a window attribute parameter 2011-07-11 17:57:52 +10:00
John Zaitseff
86b88e8929 Allow a player to quit at the first prompt ("Enter number of players") 2011-07-11 17:48:16 +10:00
John Zaitseff
cdaeb2e869 Add the init_game() function that initialises the actual game 2011-07-11 16:14:07 +10:00
John Zaitseff
2a3ed550ad Remove the clrline parameter from the center() function 2011-07-11 15:56:01 +10:00
John Zaitseff
4a555235c9 Add the attr parameter to the center() function 2011-07-11 15:45:38 +10:00
John Zaitseff
20f6f6e73a Add the wait_for_key() function 2011-07-11 14:43:16 +10:00
John Zaitseff
5055ea57ac Rename get_yn_answer() to answer_yesno() 2011-07-11 14:23:16 +10:00
John Zaitseff
6436a68f8b Add the prototype and an empty definition for show_help() 2011-07-11 13:57:14 +10:00
John Zaitseff
3ff949efc0 Print the result of the get_yn_answer() function in bold 2011-07-11 13:52:22 +10:00
John Zaitseff
019734c8aa Rename the function getanswer() to get_yn_answer() 2011-07-11 13:37:48 +10:00
John Zaitseff
36a3811cd1 Add the gettxstring() function 2011-07-11 13:18:26 +10:00
John Zaitseff
60ab28c711 Add the modified status variable to gettxline()
Also correct a bug in gettxline() that always returned OK!
2011-07-11 12:28:13 +10:00
John Zaitseff
42e05ee20b Replace individual colour/window attributes with ATTR_ macros 2011-07-11 11:40:52 +10:00
John Zaitseff
dd281f795b Add gettxline() to read a line of input from the keyboard 2011-07-11 10:31:19 +10:00
John Zaitseff
85e09ab4f2 Replace calls to wprintw() with waddstr() where appropriate 2011-07-11 08:05:36 +10:00
John Zaitseff
1995a6a7b0 Remove the superfluous argument attr_end from attrpr()
Instead of using attr_end, simply restore the old window attributes after
printing the string.
2011-07-11 08:01:18 +10:00
John Zaitseff
5e912e6e14 Plan ahead to reduce the title window to a single line
By reducing the title window to a single line, we can fit an extra two
lines of the galaxy map in an 80x24 terminal window.
2011-07-05 10:11:50 +10:00
John Zaitseff
ad4ed4d744 Add input routines gettxchar() and getanswer(); add various macros
In particular, add macros for KEY_TAB, KEY_RETURN and KEY_ESC, and for
CURS_ON and CURS_OFF (instead of using CURS_INVISIBLE and CURS_VISIBLE
directly: this allows redefining CURS_ON to be CURS_NORMAL).  Add more
colour pairs.
2011-07-04 22:02:01 +10:00
John Zaitseff
568c3738b2 Add the attrpr() function; add a missing va_end() call in center()
The attrpr() function prints a string with a particular set of Curses
attributes.
2011-07-04 19:41:55 +10:00
John Zaitseff
ca64093a07 Move definition of "enum curs_type"; rename CURS_VERYVISIBLE
Rename CURS_VERYVISIBLE to CURS_VISIBLE to match the system documentation
for Curses.
2011-07-04 19:15:38 +10:00
John Zaitseff
4279467e14 Define the global variable quit_selected 2011-07-04 18:24:10 +10:00
John Zaitseff
ad10fd4af6 Rename company_names[] to company_name[] for consistency 2016-12-09 08:55:09 +11:00
John Zaitseff
9f6c2af671 Define ATTR: select between attributes for colour and mono screens 2016-12-09 08:54:59 +11:00
John Zaitseff
10c4cb2a22 Add a "y" parameter to center(); add the COL_CENTER macro 2011-07-04 17:54:30 +10:00
John Zaitseff
c0943b9f7d Move (and abstract) the random number functions to utils.c 2011-07-04 17:13:29 +10:00
John Zaitseff
9a39c84bf4 Add source files game.c and game.h
These files will eventually contain many of the game functions.
2011-07-04 15:54:39 +10:00
John Zaitseff
4d5c5b70ca Add the functions init_program() and end_program() 2011-07-04 15:45:03 +10:00
John Zaitseff
4f62ef1b58 Add simple functions to manage a stack of Curses windows 2011-07-04 12:41:30 +10:00
John Zaitseff
2a3e18460e Rename intto_game_filename() to game_filename() 2011-07-04 10:28:50 +10:00
John Zaitseff
d9ff917835 Rename MIN_COLUMNS to MIN_COLS for consistency with the COLS variable
Also define WIN_COLS and WIN_LINES: the current version of Star Traders
will only use this number of lines and columns in a terminal window.  All
calls to newwin() need to have COL_OFFSET and LINE_OFFSET added to the X
and Y starting positions to make this work.
2011-07-02 23:19:40 +10:00
John Zaitseff
3aa98f48bd Add the files help.c and help.h
These file will eventually contain help text describing how to play the
Star Traders game.
2011-07-02 21:50:47 +10:00
John Zaitseff
abd196d2c5 Add the basic I/O functions init_screen(), end_screen() and center() 2011-07-02 21:25:57 +10:00
John Zaitseff
0af905e1d9 Use PACKAGE_NAME where appropriate 2011-07-02 21:19:51 +10:00
John Zaitseff
9e4e4b6d11 Add intf.h and intf.c: basic text input/output interface routines 2011-07-02 14:53:45 +10:00
John Zaitseff
6c90801102 Add the err_exit() and errno_exit() functions 2011-07-02 14:23:35 +10:00
John Zaitseff
162062cbfb Rearrange the __attribute__ compiler directive
The __attribute__ compiler directive should be placed AFTER a function
prototype, as per the GNU C Compiler manual.
2011-07-02 14:01:32 +10:00
John Zaitseff
d5951adb4f Redefine the cursor type as an enum instead of as macros 2011-07-02 12:47:51 +10:00
John Zaitseff
e8590e68eb Add README files to the src and doc subdirectories 2011-07-02 10:17:03 +10:00
John Zaitseff
e8bdcfe304 Remove premature provisions for internationalisation
In particular, remove the use of the "_" macro: real internationalisation
may require this macro in a different form from that used here.
2011-07-02 10:01:37 +10:00
John Zaitseff
ba721ced10 Be stricter about saved game numbers 2011-07-02 09:39:23 +10:00
John Zaitseff
ee94d86b57 Add some more definitions, especially for the Curses library 2011-06-30 21:52:55 +10:00
John Zaitseff
9453cfc402 Use the C99 <stdbool.h> header file 2011-06-30 21:11:36 +10:00
John Zaitseff
3a4c95f927 Add the SysV-compatible curses library
The AX_WITH_CURSES macro is taken from the autoconf-archive project,
available at http://www.gnu.org/software/autoconf-archive/.
2011-06-30 20:31:19 +10:00
John Zaitseff
d6050858d9 Add the __attribute__((noreturn)) function specifier where possible 2011-06-30 16:09:13 +10:00
John Zaitseff
7fa5833fb6 Complete the command line argument processing routines 2011-06-30 15:25:30 +10:00
John Zaitseff
255dc9aa19 Add the process_cmdline(), show_version() and show_usage() functions 2011-06-29 13:15:26 +10:00
John Zaitseff
bdcdf2f131 Add the max_turn, game_loaded and game_filename global variables 2011-06-29 13:09:40 +10:00
John Zaitseff
6910370557 Add various header files
Add the system.h header file for all system header includes, and utils.c
and utils.h for various low-level utility functions.
2011-06-15 22:34:28 +10:00
John Zaitseff
ced3697fe1 Add the MAP_LAST enumeration constant 2011-06-15 19:39:07 +10:00
John Zaitseff
ab6f936f3f Rename the global variables map and move
Rename the global array variables map[] and move[] to galaxy_map[] and
game_move[] respectively to prevent clashes with functions from various
libraries (particularly NCurses).
2011-06-15 13:05:14 +10:00
John Zaitseff
18fde51d30 Add global constants, type definitions and variables to the game 2011-06-15 12:55:19 +10:00
John Zaitseff
38d7a0e022 Add missing #include directives 2011-06-14 23:19:58 +10:00
John Zaitseff
c9cf917763 Rename header #define to conform to relevant C language standards
Although widely used, macro definitions starting with "__" (amongst
others) are reserved by the C programming language standard for the
compiler and standard header files to use in any way desired.
2011-06-14 23:11:16 +10:00
John Zaitseff
305be1e852 Add a simple main() routine for testing 2011-06-14 23:02:16 +10:00
John Zaitseff
3187aaf10c Remove superfluous version and date information 2011-06-14 23:01:15 +10:00
John Zaitseff
6a69114d64 Add build infrastructure for basic processing of various subdirectories 2011-06-14 22:55:48 +10:00
John Zaitseff
c79ad6b99d Add the basic infrastructure required by autoconf and automake 2011-06-14 22:16:26 +10:00
John Zaitseff
c39b6019e2 Remove quote characters surrounding filenames 2011-06-14 21:59:48 +10:00
John Zaitseff
f66fb88c69 Create preliminary versions of the source code and manual page 2011-06-14 18:19:01 +10:00