Skip to content

Proposed misc stuff#1

Open
lindi2 wants to merge 54 commits intotriplane-classic:masterfrom
lindi2:proposed-misc-stuff
Open

Proposed misc stuff#1
lindi2 wants to merge 54 commits intotriplane-classic:masterfrom
lindi2:proposed-misc-stuff

Conversation

@lindi2
Copy link
Contributor

@lindi2 lindi2 commented Sep 27, 2019

Do not merge this pull request yet. This contains a collection of proposed patches from me and Riku and should probably be split to smaller pull requests.

rsaikkon and others added 30 commits November 5, 2017 15:43
Functional change: the (undocumented) -level option previously had the
syntax -levelLEVELNAME - now it is -level LEVELNAME to be more
consistent with other options.
Every Bitmap object now stores a unique integer id, which is the index
where it is located in the all_bitmaps array. This makes
all_bitmaps_delete much more efficient.
Don't try to draw a bitmap that is completely outside the clip
rectangle.
all_bitmaps_refresh() should be called whenever the palette
changes (not only after a video mode change), otherwise the bitmaps
may have incorrect colors. Except we still don't do it when only the
water colors are rotated, because that would be too slow - making
water work in -sdldraw mode would require more extensive changes.

This only affects -sdldraw mode (in the default drawing mode,
all_bitmaps_refresh() does nothing).
Made fillrect update vircr by itself (previously its callers had to do
it).
Previously the four "national" music files were loaded and unloaded
when needed (and the two others at the start). Now all music is
preloaded when Triplane starts, as is done with samples.
A small extension to the Bitmap class constructor.
Replace many variations of kbhit/getch/koords/wait_mouse_relase loops
with unified menu_keys and menu_mouse functions. Also let keyboard
keys emulate mouse buttons: Space = left button, Enter = right button.

Minor functional changes: the Credits and "letter" menus can now be
exited only with Enter, Space, Escape or mouse buttons (any key worked
previously); and the small_warning dialog can be canceled with Escape
(previously only the mouse worked).

Also clean up kbhit(), getch() and select_key(), fixing some bugs:

Make getch() return 0 when the event queue is empty (previously it could
get stuck in a busy loop, e.g. when pressing Shift in certain menus).

Make kbhit() clear the event queue when it returns false (previously
some loops could keep unprocessed events in the SDL event loop
indefinitely).

Adjust all callers of getch() to check kbhit() first and call do_all()
in their loop.

Make select_key() use getch() instead of a custom loop.

Moved "key" array and wait_relase() to sdl_compat.cpp where they fit
better, and add a delay into the busy loop of wait_relase().
The Tab key can now be used to move to any selectable items in the
menus (and the mouse-button-emulation keys Space and Return can be
used to select them).
All menus can now be navigated with the arrow keys (in addition to Tab
and the mouse).
do_aftermath uselessly called do_all a few times.
Clean up main_menu() by moving code that sets some game type -related
variables into a new function.
Read player controls in a separate function instead of inside the main
game loop code. Add set_keys_* functions which are used to set where the
current controls come from.
It is now possible to assign an anonymous pilot for multiplayer (not
solo) games. It works like a normal human pilot except that nothing is
saved in the roster for this player.

Also fixes a bug where the up/down arrows in the Assign Players menu
allowed switching to an empty player name (which was removed when
exiting the menu).
Just releasing a mouse button press which resulted in a warning dialog
could exit the warning dialog if the mouse cursor happened to be on
top of the warning dialog buttons.
SDL 2.0 supports scaling to arbitrary window sizes and
normal-resolution full-screen mode.
Support for playing over the network (LAN or Internet, but the server
needs to be able to receive incoming TCP connections). It is
controlled via a new Network game menu and new parts of the Assign
players menu. The network game works, but is a bit unpolished, and
there is no documentation yet.

The network game uses the zlib compression library, which is now
needed to compile Triplane.

This commit adds new network game-related fields to the end of the
Triplane configuration file triplane.cfg. Old configuration files are
read and converted automatically.
A nonexistent player could sometimes reserve a network game client for
itself. When the network game menu asked for the client name, it did
not clear the previous name from the screen.
The Assign Players menu now tries to auto-allocate players for the
network game based on their preferences.
rsaikkon and others added 24 commits November 5, 2017 19:29
Initialize player name when solo controls selection first becomes
visible.
An image for a bigger warning dialog already existed, now we also have
a function that uses it.
Warning/error messages from the network game client can be large
enough not to fit in the small_warning dialog, so use the bigger one.
Connecting to the server can now be aborted with Esc.
This new OVFONT should be readable on top of any screen of the game,
and is now used for network game-related overlay texts. The current
font file is just gridfont ("frost") converted to dark blue, which is
only barely readable on some backgrounds.
Now the client shows "Viewing screen from host" when in a menu, and no
extra text (only possible chat messages etc.) when in the game.
The network game host starts in the Assign Players menu, but now it
also disables any existing solo players, so that auto-allocation of
controls and players is performed for a multiplayer game. (Presumably
network games are usually multiplayer.)
Close a new client connection if no greeting packet (which must be the
first packet) is received in 15 seconds.
New methods for changing colors and adding an outline to existing
Bitmap objects.
When creating a Font object from a bitmap, now the foreground color of
a monochrome font can be changed, and characters in the font can be
outlined with a provided color.
Make the overlay font in the network game use the new font recoloring
and outlining support, instead of the hand-crafted font file that was
introduced in commit 4231f3dd4213e9906ff8049f12fcb68c5701d706. Remove
that font file, as an identical font can be created from gridfont with
the new font recoloring support.
The server now send ping messages about every two seconds, and
disconnects clients if they have not replied in about 20 seconds.

This is done to get a more accurate view of which players are
connected. More importantly, if a client or network connection gets
stuck for some reason (without the TCP connection closing cleanly),
the ping timeout allows the player to reconnect using the same player
name (and thus continue controlling a plane) after waiting for the 20
seconds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants