John Zaitseff
bf76fa312c
Assume MOD_POSIX_CURRENCY_SYMBOL contains only ASCII characters
...
The GNU library now has "C.UTF-8" as a locale (which is NOT a single-byte
locale!), but we assume the currency symbol in MOD_POSIX_CURRENCY_SYMBOL
contains only ASCII characters.
2011-08-16 20:55:42 +10:00
John Zaitseff
d20cc2b5ec
Use chstr-style output functions in gettxline()
2011-08-16 20:45:47 +10:00
John Zaitseff
de6a4e3e66
Remove obsolete old_attrpr, old_center, old_center2 and old_center3
2011-08-16 18:51:56 +10:00
John Zaitseff
cf30933614
Continue to rewrite the interface code to use the new interfaces
2011-08-16 18:48:56 +10:00
John Zaitseff
135842b87d
Bug fix for non-colour mode
...
If the background has A_REVERSE, then A_NORMAL will have no effect. For
that reason, specify A_NORMAL as the default background after creating a
new window.
2011-08-16 16:25:28 +10:00
John Zaitseff
82647cf691
Move to the new left/center/right functions; add maxlines parameter
2011-08-15 23:54:44 +10:00
John Zaitseff
22677c0d89
Handle floating-point numbers in mkchstr(), with optional precision
2011-08-15 23:12:10 +10:00
John Zaitseff
665605d144
Add convenience functions left(), center() and right()
2011-08-15 21:04:07 +10:00
John Zaitseff
a6c362d2e8
Rename pr_left, pr_center and pr_right to leftch, centerch and rightch
2011-08-15 19:46:26 +10:00
John Zaitseff
907a995b98
Refactor function names; "old_" functions will be removed
...
Rename prepstr, vprepstr, chbufdup, center, center2, center3 and attrpr
to mkchstr, vmkchstr, chstrdup, old_center, old_center2, old_center3 and
old_attrpr respectively.
2011-08-15 19:12:26 +10:00
John Zaitseff
0c319738a8
Continue to move code to prepstr() and friends
2011-08-15 17:07:00 +10:00
John Zaitseff
3ad62688da
Do parse of format string in prepstr_parse(); add the "%c" specifier
2011-08-15 15:53:56 +10:00
John Zaitseff
746155078b
Continue to move text output to the new interfaces
2011-08-15 10:08:44 +10:00
John Zaitseff
5bb48fe35f
Add wrapper functions xmalloc() and xstrdup() to do error handling
2011-08-13 08:50:34 +10:00
John Zaitseff
c50b8a4649
Move error handling into vprepstr(), to save doing it over and over
2011-08-13 08:17:30 +10:00
John Zaitseff
06b66716cf
Add the function chbufdup() to duplicate a chtype array
2011-08-13 07:59:20 +10:00
John Zaitseff
7d9bf097b9
Replace discrete calls to newtxwin() etc. with calls to txdlgbox()
2011-08-12 18:24:35 +10:00
John Zaitseff
184c07d19d
Add a comment about multibyte character handling in prepstr()
2011-08-12 16:35:13 +10:00
John Zaitseff
15f06bdc79
Move some functions from center() to pr_center()
2011-08-12 16:32:32 +10:00
John Zaitseff
b27af38537
Minimise flickering when resizing the console window
2011-08-12 16:09:38 +10:00
John Zaitseff
6594ff3daa
Add the function txdlgbox() to display a dialog box
2011-08-12 16:02:01 +10:00
John Zaitseff
4e7699f192
Add vprepstr() with a va_list argument: for the future txdlgbox()
2011-08-12 15:10:05 +10:00
John Zaitseff
2612eddf3d
Add functions prepstr(), pr_left(), pr_center() and pr_right()
...
These functions allow multiple lines to be printed left-aligned, centered
or right-aligned, with automatic line-wrapping where needed.
2011-08-12 14:28:15 +10:00
John Zaitseff
3984468894
Handle KEY_RESIZE events (where defined) in a simple manner
...
Unfortunately, the implementation of Curses (even Ncurses) requires that
to truely handle resizing, one must destroy and recreate every window
(and, of course, repaint it)--a lot of work that is not done at this
time.
2011-08-10 01:27:11 +10:00
John Zaitseff
738ffcd69a
Block SIGINT, SIGTERM and SIGQUIT when in the signal handler
2011-08-10 00:30:38 +10:00
John Zaitseff
040e1a5ad6
Rework the signal handler
...
Rework the signal handler to be somewhat more unsafe, but conceptually
cleaner, in operation. It now ends the use of Curses, then reraises the
signal. Remove almost all references to abort_game.
2011-08-09 23:20:56 +10:00
John Zaitseff
5f995f1d36
Move the initialisation of the game title into its own function
2011-08-09 13:11:22 +10:00
John Zaitseff
8a2bc51f28
Rearrange function prototypes to match the order in the source file
2011-08-09 13:06:21 +10:00
John Zaitseff
4d133cf662
Rework the definition of USE_UTF8_GAME_FILE a little
2011-08-09 12:27:56 +10:00
John Zaitseff
bbdae69de4
Add a signal handler for SIGINT and SIGTERM
...
Add a signal handler for SIGINT and SIGTERM, as well as sprinklings of
checks to abort_game. Although Ncurses DOES define handlers for SIGINT
and SIGTERM, they do not always seem to work correctly under many
operating systems.
2011-08-08 20:47:52 +10:00
John Zaitseff
32ed55a0cd
Convert strings to UTF-8 if possible during file save and load
2011-08-08 11:15:44 +10:00
John Zaitseff
1e7c6c098a
Add checks for the C.UTF-8 (C.utf8) locale for adding a currency symbol
2011-08-08 10:21:24 +10:00
John Zaitseff
601678313d
As much as I don't like it, change the help string to American spelling
2011-08-01 20:52:40 +10:00
John Zaitseff
c7e1f6096f
Replace PACKAGE_NAME with "Star Traders"
...
The gettext utilities don't like C macros in gettext() invocations, so
replace each occurrence of PACKAGE_NAME with "Star Traders".
2011-08-01 19:49:16 +10:00
John Zaitseff
1ee27fda20
Minor modifications to allow the first pass to compile!
2011-08-01 19:43:55 +10:00
John Zaitseff
9251ca0463
First pass at adding _() and N_() to allow string translation
2011-08-01 19:30:19 +10:00
John Zaitseff
686b3b0e0e
Rearrange order of linked libraries; move definition of LOCALEDIR
2011-08-01 18:59:11 +10:00
John Zaitseff
378b7e64b0
Add preliminary support for GNU gettext internationalisation
2011-08-01 18:17:02 +10:00
John Zaitseff
48e8bbba93
Complete rewrite of the M4 macro that checks for Curses
2011-07-28 21:19:33 +10:00
John Zaitseff
8240043880
Move <stdio.h> to appear before <stdlib.h>
...
This is required on some systems, such as Darwin (MacOS X).
2011-07-26 20:40:33 +10:00
John Zaitseff
e7fee29e5b
Final minor edits of various documentation files
2011-07-25 17:00:59 +10:00
John Zaitseff
fd55a09493
Add support for the Gnulib portability library
...
In particular, the gnulib-tool utility now maintains lib/Makefile.am, as
well as many files in the m4 and lib directories. The file
m4/gnulib-cache.m4 allows the Gnulib files to be refreshed. See
http://www.gnu.org/software/gnulib/ .
2011-07-23 17:19:07 +10:00
John Zaitseff
961e989bd7
Replace the WCENTER(x) macro with WCENTER; refactor newtxwin() to suit
2011-07-23 10:16:03 +10:00
John Zaitseff
a5feeb2635
Add a call to turn the cursor on--just in case
2011-07-23 10:04:09 +10:00
John Zaitseff
fc60a9fef1
Rework the handling of character renditions
...
Rather than querying use_color each and every time a rendition is used,
do it once in init_screen(), assigning the renditions to global
variables.
2011-07-23 09:47:13 +10:00
John Zaitseff
6704c358ce
Make compiler quieter about signed and unsigned comparisons
2011-07-22 13:07:14 +10:00
John Zaitseff
27167f0e6f
Finish moving all comments from source files to headers
...
At this point, the source code of Star Traders is essentially ready for
its 7.0 release!
2011-07-22 13:05:06 +10:00
John Zaitseff
b3e58af2eb
Be consistent in naming all "long int" variables that way
2011-07-22 12:59:05 +10:00
John Zaitseff
e50ce0e12b
Add more comments to process_move()
2011-07-22 12:43:21 +10:00
John Zaitseff
df2608d2d4
Make module-specific internal functions static
2011-07-22 12:31:54 +10:00
John Zaitseff
65a9dacbfc
Change the "--no-encrypt" command line option to "--dont-encrypt"
...
Some versions of getopt_long() show ALL options if an ambiguous
abbreviation was supplied (such as "--no"), and we don't really want
players to discover this option by accident, do we? :-)
2011-07-22 12:20:58 +10:00
John Zaitseff
c18f913710
Document the --max-turn command line option
...
Do NOT document the --no-encrypt option: we don't want people to know
about it!
2011-07-22 12:16:09 +10:00
John Zaitseff
ac55800e90
Continue moving comments from source files to headers
...
Also refactor some code, primarily in process_move(), to reduce the level
of indentation.
2011-07-22 12:11:19 +10:00
John Zaitseff
37195a1c57
Refactor some code in init_game()
...
Move parts of the code out of init_game() to internal functions
ask_number_players(), ask_game_number() and ask_player_names(). Also
move comments out to game.h as appropriate.
2011-07-22 10:49:26 +10:00
John Zaitseff
4b4efd7851
Replace the global variable localeconv_info with lconvinfo
...
In general, verbosity is not really to be encouraged...
2011-07-22 10:23:58 +10:00
John Zaitseff
9ef1181c05
Revert a previous change: we know how large is the window we opened!
2011-07-22 10:08:43 +10:00
John Zaitseff
78cac96e4a
Change handling of setlocale(LC_NUMERIC) in load_game() and save_game()
...
Changing just the LC_NUMERIC part of the locale DOES work, if you read
the manual page carefully! In particular, TWO calls need to be made, the
first with parameter NULL to get the current locale. In addition, the
result MUST be copied to a new string, as it may be (and is!) overwritten
by the next call to setlocale().
2011-07-21 22:44:45 +10:00
John Zaitseff
71486357c1
Bug fix: restore locale settings correctly
...
For some reason, changing the locale to "C" for LC_NUMERIC, then
restoring just that part of the locale to the old user-supplied
one does not work. Simply reinstating the whole locale using
setlocale(LC_ALL, ""), however, DOES work, so do that.
2011-07-21 22:22:50 +10:00
John Zaitseff
c5500e1bb3
Document and clean up fileio.c: functions load_game() and save_game()
2011-07-21 22:18:14 +10:00
John Zaitseff
1ac4d28c21
Document and clean up functions in intf.c
...
Document gettxline(), gettxstr() (formerly gettxstring()), gettxdouble()
and gettxlong().
2011-07-21 21:40:54 +10:00
John Zaitseff
1408a2ab3d
Allow a second default key, ";" as well as "=", to help touch-typists!
2011-07-21 13:16:42 +10:00
John Zaitseff
ee992fa02a
Move printing a prompt into answer_yesno(); document wait_for_key()
2011-07-21 13:10:51 +10:00
John Zaitseff
eac09fecb5
Move function descriptions to the intf.h header file
...
Also change the types of character rendition (attributes) variables from
int to chtype; add restrict where suitable and rewrite parts of the
functions to use getattrs().
2011-07-21 12:29:13 +10:00
John Zaitseff
1a44ff6513
Replace "tv.tv_sec * tv.tv_usec" with "tv.tv_sec + tv.tv_usec"
...
This allows the lower bits of seed to hopefully contain something useful
instead of just zeros!
2011-07-20 23:19:12 +10:00
John Zaitseff
a9f52e89be
Move function comments from source to header files where they belong
2011-07-20 22:41:56 +10:00
John Zaitseff
6a6c31035a
Correct a subtle off-by-one error in copying in l_strfmon()
...
The bug in l_strfmon() is that bufsize is NOT the length of the string,
hence do not include the usual "+ 1" for the NUL byte. Also correct some
comparisons between signed and unsigned integers.
2011-07-20 21:47:20 +10:00
John Zaitseff
b3f1820418
Add the restrict keyword where appropriate
2011-07-20 21:18:49 +10:00
John Zaitseff
6ee474e438
Minor code cleanups
2011-07-20 21:18:28 +10:00
John Zaitseff
9f02f8e77f
Rename character renditions (attributes) to something more regular
2011-07-20 17:01:25 +10:00
John Zaitseff
6a9af29c31
Rearrange some lines in intf.h; add additional comments
2011-07-20 16:12:02 +10:00
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