Commit Graph

116 Commits

Author SHA1 Message Date
Zack Middleton 10abac8fa0 Fix duplicate bots displayed in Team Arena ingame add bot menu
The key handler allowed going 2 beyond the end of the bot list and the
display function clamped to 0 causing the first bot to be shown 3 times.

Attempting to add the bot in gametypes < GT_TEAM would fallback to
Sarge in UI_GetBotNameByNumber() (who isn't the first bot) and gametypes
>= GT_TEAM would access characterList past known values (typically NULL
but if teaminfo.txt contained 63 characters it would access out of
bounds memory).
2018-05-06 01:47:49 -05:00
Zack Middleton 45f8512f8e Fix clearing keys for control in Team Arena UI
When a control is selected for binding a key, pressing backspace would
clear the displayed keys in the menu but not actually unbind the keys.
2018-04-26 11:47:11 -05:00
Zack Middleton 3377f9981a Fix map list in Team Arena start server menu after entering SP menu
In September 2017 I moved loading arenas.txt/*.arena files from entering
start server menu to at startup to fix running out of memory in Team Arena
UI after opening the start server menu several times.

However, Team Arena completely replaces the uiInfo.mapList array when
switching between single player and start server menus. So after my
change, entering single player and then entering start server would only
display single player maps. It caused SP endofgame menu to use MP map
list for replay/next map since arenas were loaded after gameinfo.txt.

Continue loading arena info at start up to avoid reallocating arena info
but move setting up uiInfo.mapList to when entering the start server
menu.
2018-04-12 01:04:54 -05:00
Zack Middleton dfb49e78b5 Make setting r_stencilbits more consistent in Team Arena UI
I changed Color Depth options 'Default' to reset r_stencilbits instead
of 0 and '32 bit' to use r_stencilbits 8 instead of not changing the
value. (This matches my q3_ui changes in the previous commit.)

Set r_stencilbits when changing graphics presets like when changing
Color Depth.
2018-04-11 02:07:27 -05:00
Edward Betts fe42b8653d Correct spelling mistakes. 2017-11-22 01:40:20 -06:00
Zack Middleton 471ea9e564 Fix Team Arena server refresh time format
Make minute less than 10 have a leading 0. Change '7:1' to '7:01'.
2017-11-10 20:06:04 -06:00
Zack Middleton 11b3bca555 Update UI player animation handling to match CGame
Fix "Error parsing animation file" messages in UI. Caused by fixing the
handling of missing tokens in animation.cfg parser in a past commit.
Fix new Team Arena torso animation frame numbers in UI.
Add support for fixedtorso and fixedlegs keywords.
Add support for reversed animations (negative numframes).
2017-09-10 20:20:30 -05:00
Zack Middleton a48dcdf224 Fix crash when out of memory in Team Arena's String_Alloc 2017-09-10 19:11:35 -05:00
Zack Middleton dcf5707493 Don't reload arenas.txt/*.arena files in Team Arena UI
Entering Team Arena's start server or in-game callvote menu causes
arenas to be reloaded. The existing memory is not freed so after
a entering the menus a few times the UI runs out of memory and
crashes.

Just load arenas once when the UI loads like in q3_ui.
2017-09-10 19:11:35 -05:00
Zack Middleton 8192f66b39 Don't draw crosshair 0 in Team Arena setup menu
Don't draw crosshair 0 in Team Arena setup menu. It isn't drawn
in CGame. Wrap cg_drawCrosshair in missionpack menu like CGame
instead of treating as index 0 which is no longer drawn.
2017-09-02 18:19:08 -05:00
Zack Middleton 9f239d647b Make 'globalservers 0' fetch all masters
This commit fixes the vanilla Q3 UI VMs not displaying a server list
when id Software's master server is down.

Originally master 0 for the globalservers command was Internet and
master 1 was MPlayer (defunct). In 2008 ioquake3 changed it so that
master 0 to 4 were five separate master servers with no affect on
original Quake3/Team Arena UI VMs; they continued to get the server
list from master.quake3arena.com.

id Software's master server (master.quake3arena.com) goes down
occasionally. Using ioq3's UI VM additional master servers can be
accessed but players using the original UI VMs are unable to get a
server list.

In order to fix the original UI VMs in Quake3/Team Arena's pk3s this
commit makes 'globalservers 0' fetch all master servers. So players
get a combined list of id Software's and ioquake3's master list. Or
just ioquake3's list if id Software's master is down.

Getting lists from individual master servers using globalservers has
changed from 0 through 4 to 1 through 5 to accommodate using 0 for
other purposes. This commit modifies ioq3's UI code to support the new
values for globalservers command.

A side affect of these changes is that UI VMs based on ioq3 since 2008
will have Internet1 fetch all master servers and Internet2 request
sv_master1 instead of sv_master2 and so on. It may be worth noting that
getting server list from masters 3-5 could not be done using ioq3's UI
before 2011.
2017-07-20 15:39:51 -05:00
Brenton Bostick a33a904225 Fix warning about using abs() with floats (#222) 2017-07-09 14:00:56 -05:00
Zack Middleton 0ba359c29e Make UI continue searching for local servers until found
When refreshing local servers, Team Arean UI never changed the status
message when it timed out. This gave a false impression it was still
looking for servers.

Let's continue looking for local servers in q3_ui and Team Arena UI
until one is found.
2017-07-01 14:17:22 -05:00
Zack Middleton 21eeaee9c8 Make Team Arena UI aspect correct in widescreen 2017-07-01 11:27:42 -05:00
Zack Middleton f7c3276fe8 Fix g_teamAutoJoin and g_teamForceBalance
There are various issues caused by not knowing the initial team for
the local client and bots when they connect. This is can be reproduced
by starting a team game from the main menu.

When g_teamAutoJoin is enabled, bots and local client join a random
team at connect and then execute their team command a few frames
later. This may result in the player being killed if they specify a
different team. In Team Arena's Harvester mode this causes harvester
skulls to be spawned at the beginning of the game.

When g_teamForceBalance is enabled, the local client and bots may not
be able to join their desired team. This may result in them being
spectators. If g_teamAutoJoin is also enabled they may be left on
the opposite (red/blue) team they were meant to join.

There is a hack for including bot's team in their player info string
(used by cgame for which team skin to use) before the bot joins
their desired team. Bots aren't guaranteed to join their desired team
(as may happen when both g_teamAutoJoin and g_teamForceBalance are
enabled) so clients may see them as being on the wrong team!

----

Add teampref userinfo option for team preference. If teampref is set
it will be used for attempting to join the team immediately at connect.

Bots now join team at connect using teampref userinfo. So remove
the hack for setting bot's team in player info string before the bot
joins the team.

To avoid the client sending teampref userinfo to all network servers,
the local client uses a g_localTeamPref cvar. The g_localTeamPref
cvar is cleared after it's used so it doesn't get used when starting
another server later. Another reason not to use a teampref userinfo
cvar is there isn't a reliable way to clear it in CGame/UI which are
likely loaded from baseq3 pk3.

Make it so g_teamAutoJoin doesn't affect clients who specify
teampref. If teampref is invalid, the client will join a random team
like g_teamAutoJoin.

Don't apply g_teamForceBalance to the local client or bots. Otherwise
they may be left as spectators when starting team game from menu.

The start server menus use team command and g_localTeamPref to set
the human player's team. This way it's compatible with vanilla Q3
game VMs and the new setting team at connect feature.
2017-06-22 21:56:20 -05:00
Zack Middleton 1048073e26 Unify checks for missing COM_Parse() token 2017-06-07 19:16:05 -05:00
Zack Middleton d58234a6c7 Fix 'missing token' in parsers for animations.cfg 2017-06-07 19:06:41 -05:00
Zack Middleton db1198f6ea Add mouse wheel support to UI list boxes
Allows scrolling server browser list and some other lists.
2017-06-03 14:03:09 -05:00
Zack Middleton 5592342b1b Only auto update empty Team Arena internet server cache
Previously tested a mod cvar which may be wrong when multiple
mods are involved or config is reset. Let's check the server
cache's internet server count directly.
2017-06-03 14:03:09 -05:00
Zack Middleton bd067540f5 Fix hitch when opening Team Arena find friend menu
Opening the find friend menu in the Team Arena server browser
hitches due to trying to resolve blank host names.

In UI_BuildFindPlayerList() status requests that are initial or
completed state or have timed out get reset. This means it starts
with MAX_SERVERSTATUSREQUESTS (16) blank host names. So just ignore
them in UI_GetServerStatusInfo().
2017-06-01 18:54:28 -05:00
Zack Middleton 0a19ae0306 Fix levelshot displayed in Team Arena server browser
Levelshot was not updated when server list was initially loaded or
server list was sorted.
2017-06-01 18:03:24 -05:00
Zack Middleton 2091a2e2d5 Fix favorite servers player count message in Team Arena UI
The console message "1 servers listed in browser with 2 players."
would count clients multiple times when viewing favorite servers.

When viewing favorite servers in Team Arena UI, servers are added
to list before getting ping response. Each time UI checked pings
and inserted server it incremented the player count.
2017-06-01 17:24:07 -05:00
Zack Middleton 6b5674e6bb Fix filtering favorite servers in Team Arena UI
Filter favorite servers based on cached server info and new info
instead of only the cached info.

If cached server info is filtered out, don't add it to server list
but wait for getinfo response before marking server as invisible.
2017-06-01 17:24:07 -05:00
Zack Middleton 2bbe178bc8 Replace constant value with UIAS_GLOBAL1 2017-06-01 17:24:06 -05:00
Zack Middleton e8f092637c Automatically get initial Internet servers in Team Arena UI
Having to manually request the list, with two buttons (get new
list, refresh list) is somewhat confusing. Also since it looks
like there are no servers, users might not try to figure out
how to get the server list.

The first time viewing a master server list in Team Arena UI,
automatically request a new server list. After that the cache
will be available with a timestamp of the last refresh time.
I think this will make it easier to understand how the menu
works.

This may cause unneeded updating of the server cache because the
last refresh timestamp is per-fs_game but the server cache is
shared by all games. This will only occur once for each game
though so it's not a big concern.
2017-06-01 17:24:06 -05:00
Zack Middleton f6f2710f94 Make server browser default to Internet
The default use to be local. In q3_ui you have to press spacebar or
wait for scan to time out before you can switch to Internet.
2017-06-01 16:58:21 -05:00
Simon McVittie 2ab109b772 Avoid 'register' declarations
gcc 6 with -Wall -Wextra warns:

code/botlib/l_precomp.c: In function ‘PC_NameHash’:
code/botlib/l_precomp.c:551:2: warning: ‘register’ is not at beginning of declaration [-Wold-style-declaration]
  int register hash, i;
  ^~~

Modern compilers either ignore the register storage class when
generating code, or generate better code without it, so just remove
most of them.

The remaining uses are in third-party bundled libraries (libjpeg, zlib),
and in a PowerPC-specific inline function consisting of inline
assembler (because I'm not 100% confident that it doesn't have
some practical use there).
2016-11-01 16:37:38 +00:00
Simon McVittie f1a133acf1 UI_BuildFindPlayerList: make a sizeof() more obviously correct
As with the other branch of the if/else, each element of
foundPlayerServerNames is in fact the same size as each element of
foundPlayerServerAddresses, so it was fine; but it's better to make
it obvious that we are using the right array sizes.
2016-09-25 17:13:50 +01:00
Simon McVittie 01bfb1540f UI_BuildFindPlayerList: avoid array underflow
This function is used in the Team Arena menus

I don't think it's actually possible to reach this line with
foundPlayerServerNames < 1, because by the time we get here we have
set it to 1 + the actual number of servers; but if we did, it would
clearly underflow into foundPlayerServerNames[-1], which would be
undefined behaviour. gcc 6 diagnoses this with a warning:

code/ui/ui_main.c: In function ‘UI_BuildFindPlayerList’:
code/ui/ui_main.c:4138:16: warning: array subscript is below array bounds [-Warray-bounds]

Also correct the sizeof() invocation to make it more obviously
correct (in fact the buffers for names and addresses happen to both
be of size MAX_ADDRESSLENGTH, so it was fine, but it's good to be
obvious).
2016-09-25 17:13:47 +01:00
Thilo Schulz bb7ad55382 Only play logo/intro if their filenames have been defined in q_shared.h 2016-06-16 03:01:21 +02:00
Zack Middleton d875c1f03c Improve keyboard/joystick input in Team Arena UI
Make Yes/No, Multi, Slider, and Bind items allow enter key to change
value without mouse over item. Add support for left and right arrow keys
and joystick button 1-4 to Yes/No, Multi, and Slider and many item
specific 'ownerdraw' key handlers.

Listbox still requires mouse hover and Team Arena main menu requires
mouse hover to get anywhere...

Enabling K_JOY1-4 to select in default key handler also caused additional
mouse button (K_AUX1-16) to select, which is done in q3_ui as well. Both
handle K_AUX equally badly (not treated as a mouse button and not handled
by item specific key handlers), so it's probably fine.
2016-05-23 09:06:34 -05:00
Zack Middleton b85935d30c Fix glyph width calculation in Text_Paint_Limit
Text_Width's scale argument will be multiplied by glyphScale, so don't
pass useScale that is already multiplied by glyphScale as this makes
the scale too big.
2015-09-15 16:56:03 -05:00
Zack Middleton c91fe0bcfe Fix handling too many teams in Team Arena UI 2015-07-13 00:09:22 -05:00
Zack Middleton af8acbd7a9 Make barrel/flash model name buffer safe 2015-01-12 22:35:20 -06:00
Zack Middleton 9c4b75c499 Remove logically dead code from UI_GetServerStatusInfo 2015-01-12 21:28:03 -06:00
Zack Middleton 78e7656900 Make Window_Paint check if w is NULL before dereference 2015-01-12 21:28:03 -06:00
Zack Middleton 84e792f453 Fix (unused) "orders" menu script logic
"orders" menu script is not used by Team Arena.

The same C format string was given an int or string argument depending on if
ordering a single person or everyone. Make it always use int.
2015-01-12 21:28:03 -06:00
Zack Middleton f74479afe8 Fix handling too many characters or aliases in Team Arena UI 2015-01-12 21:28:02 -06:00
Zack Middleton 07eb0f6dc9 Fix possible string buffer overflows in Team Arena UI 2015-01-12 21:28:02 -06:00
Zack Middleton 5020361be4 Fix off-by-one range checks in Team Arena UI 2015-01-12 18:31:39 -06:00
Zack Middleton b21a59af8c Fix negative glyph index in Team Arena text functions
Team Arena's text functions cast signed char values to int and use as an array index.
This works fine for values 0 to 127, but not for -128 to -1 which are a negative array index.
Instead use "character & 255" like client and original Q3 ui/cgame string drawing code.
2014-12-01 22:14:58 -06:00
Tim Angus b55809b925 Fix ui warnings 2014-09-01 11:05:46 +01:00
Tim Angus 621a72e698 Fix a few warnings 2014-08-30 17:29:23 +01:00
Ensiform af79d2cb38 Fix an invalid null deref check in the slider code. 2014-05-29 22:27:00 -05:00
Zack Middleton a3c2f77236 Fix Gauntlet barrel axis in UI
UI's PositionRotatedEntityOnTag is different than CGame's and
UI has switched pitch/roll for Gauntlet/BFG axis to get it to
look like /close to/ how it looks in CGame.

Making UI use the same *PositionRotatedEntityOnTag and axis as
CGame fixes the Gauntlet blade being wobbly in controls menu.
2014-05-18 20:38:14 -05:00
Zack Middleton 2ba7a33715 Have ui_test cmd in missionpack ui return qtrue 2013-12-07 21:27:17 -06:00
Zack Middleton fcaab903d1 Fix UI parse message for menu files
Missing a space after colon.
2013-09-19 21:41:27 -05:00
Razish 61dd609aee Fix warning message in animation.cfg parsing functions
Signed-off-by: Zack Middleton <zturtleman@gmail.com>
2013-09-04 15:51:34 -05:00
/dev/humancontroller 120e296a74 fix some OOB enumerator usages
(should be no-op with usual compiler workings)
2013-05-30 15:48:49 -05:00
Zack Middleton db68f59281 Fix comment for gametype parsing in ui 2013-02-27 16:09:10 -06:00