Bug 4733 - [patch] Q3UI: Clamp gametype to 4, there is no gametype 5
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: GIT MASTER
Hardware: PC All
: P3 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2010-08-28 12:23 EDT by Zack Middleton
Modified: 2011-02-04 09:45:02 EST
1 user (show)

See Also:


Attachments
Clamp gametype to 4, there is no gametype 5 (643 bytes, patch)
2010-08-28 12:23 EDT, Zack Middleton
Revert r1796, fix clamping. (1.16 KB, patch)
2010-12-17 17:24 EST, Zack Middleton

Description Zack Middleton 2010-08-28 12:23:30 EDT
Created attachment 2423 [details]
Clamp gametype to 4, there is no gametype 5

Q3UI clamps gametype to the range of 0 to 5, but there is no gametype 5 so it should clamp to 4.
Comment 1 Thilo Schulz 2010-08-29 13:08:52 EDT
There are several more game types defined in bg_public.h. Even they may not be technically implemented, clamping it to a value of GT_MAX_GAME_TYPE - 1 is technically more correct. Also, it won't break anything.
Comment 2 Zack Middleton 2010-08-30 15:45:00 EDT
GT_MAX_GAME_TYPE - 1 is technically more correct, but s_serveroptions.gametype would be able to go past the end of the gametype_remap2 array in ServerOptions_LevelshotDraw (which is the only reason to clamp it anyway).
Comment 3 Thilo Schulz 2010-09-01 07:50:21 EDT
check out what i did in rev 1796.
Comment 4 Zack Middleton 2010-09-01 12:13:15 EDT
Thilo, those gametypes are used in the missionpack (Quake III: Team Arena). Missionpack will not work now. You could add a enum value (GT_MAX_Q3UI_GAME_TYPE = 4), but it would probable be best to keep q3_ui only stuff in q3_ui.

Maybe clamp to the length of the gametype_remap2 array? (That is why it must be clamped, so it will always be correct.)

s_serveroptions.gametype = (int)Com_Clamp( 0, ARRAY_LEN(gametype_remap2) - 1, trap_Cvar_VariableValue( "g_gametype" ) );
Comment 5 Zack Middleton 2010-12-17 17:24:27 EST
Created attachment 2537 [details]
Revert r1796, fix clamping.

The missionpack is still broken. The attached patch fixes the missionpack and closes this bug.
Comment 6 Thilo Schulz 2011-02-04 09:45:02 EST
Yeah, I am still unable to understand how I came to the conclusion these gametypes are not used. I like this second patch better. Fixed in r1845