Pages: [1]
  Print  
Author Topic: Single Player Menu issue  (Read 13381 times)
dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« on: November 07, 2007, 01:21:23 AM »

gametypes higher than 9 do not parse with the current menu system thanks to this block of code from Maplist_parse in ui/ui_main.c

Quote
while (1) {
            token = COM_ParseExt(p, qtrue);
            if (token[0] >= '0' && token[0] <= '9') {
               uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030));
               if (!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].timeToBeat[token[0] - 0x30])) {
                  return qfalse;
               }
            }

Any ideas on how to get around this limitation?  (No multi-character constants allowed so upping 9 to 12 is out for the people that don't know)
Logged

iLeft.bye
Member


Cakes 1
Posts: 187



« Reply #1 on: November 07, 2007, 06:34:16 AM »

if (token[1] >= '0' && token[1] <= '9')
and use atoi for token
:/ probably not the right way

if token is an int no need to token[0] >= blah
just atoi(token)
Logged
dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« Reply #2 on: November 07, 2007, 04:20:05 PM »

if (token[1] >= '0' && token[1] <= '9')
and use atoi for token
:/ probably not the right way
if token is an int no need to token[0] >= blah
just atoi(token)

if token is an int then you get pointers between chars and ints, so you _have_ to remove the token[0] >= blah crap

It's a brilliant system if you only have 10 gametypes (which makes me wonder why they made the max_gametypes 16 when the ui will only parse 10)
Logged

beast
Lesser Nub


Cakes 0
Posts: 142



« Reply #3 on: November 07, 2007, 05:03:25 PM »

gametypes higher than 9 do not parse with the current menu system thanks to this block of code from Maplist_parse in ui/ui_main.c

Quote
while (1) {
   token = COM_ParseExt(p, qtrue);
   if (token[0] >= '0' && token[0] <= '9') {
      uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030));
      if (!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].timeToBeat[token[0] - 0x30])) {
         return qfalse;
      }
   }

Any ideas on how to get around this limitation?  (No multi-character constants allowed so upping 9 to 12 is out for the people that don't know)

COM_ParseExt returns token and it should be the value for the game type. I dont see any limitation for the number of characters that will be there. It seems that token will be whatever is there up to the next white space. Unless I am missing something here, you should be able to change it to...

Code:
while (1) {
token = COM_ParseExt(p, qtrue);
if (token[0] >= '0' && token[0] <= '9') {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (atoi(token));
if (!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].timeToBeat[atoi(token)])) {
return qfalse;
}
}
« Last Edit: November 07, 2007, 05:05:08 PM by beast » Logged
dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« Reply #4 on: November 07, 2007, 05:34:17 PM »

That works in a nice non-invasive manner, thank you.
Logged

beast
Lesser Nub


Cakes 0
Posts: 142



« Reply #5 on: November 07, 2007, 05:48:11 PM »

You might want to consider some checking in there, though. The line:

Quote
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030));


left shifts 1 by the value returned from the atoi. This should probably have a check to make sure that it is not larger than the number of bits in typeBits ( declared as an int). Also, the line:

Quote
if (!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].timeToBeat[token[0] - 0x30])) {

references an index value for timeToBeat. This value should probably be checked for out of range also. I think the timeToBeat array size is declared as MAX_GAMETYPES
Logged
dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« Reply #6 on: November 07, 2007, 06:20:16 PM »

I'm not to sure that these would be issues, they are only used in single player mode.  Added maps use the old .arena / arenas.txt system without timetobeat and would only be accessible through the create server menu (not the single player).

I will consider it, though, because there is potential there for some hooliganism.
Logged

beast
Lesser Nub


Cakes 0
Posts: 142



« Reply #7 on: November 07, 2007, 07:59:20 PM »

Agreed. I am just always over protective of code that may get influenced by outside entities.

I have not checked, but I am assuming that you have verified that the code that writes the values out will write the gametype correctly when it is > 9...
Logged
dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« Reply #8 on: November 07, 2007, 08:29:10 PM »

gametype >=11 seem to work correctly in single player
gametype 12 (domination) doesn't get populated with bots (but there are also other issues with the gametype)
its a different engine related bug


The only real issue is last man standing (gametype 10) which is an FFA gametype that is being treated as a team game, I'm debating on whether to allow FFA gametypes in single player (which brings a host of issues, like populating maps with bots) or to keep it like id's team arena with just team gametypes in single player.

That's open for discussion, so if anyone wants to pipe in, do so.
« Last Edit: November 07, 2007, 10:10:38 PM by dmn_clown » Logged

iLeft.bye
Member


Cakes 1
Posts: 187



« Reply #9 on: November 08, 2007, 03:37:48 AM »

uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030));
token[0] - 0x030 is just atoi(token[0])

probably typeBits are used for mixing game types

so dunno you may need to set FFA bit
since I dont know what the typeBits is I cant say anything

edit: if you are using atoi you may look at ui: .menu int parsing methods
instead of if (token[0] >= '0' && token[0] <= '9')
it uses if (token && token[0] != 0)
Int_Parse @ ui_shared.c
« Last Edit: November 08, 2007, 03:43:58 AM by fork » Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #10 on: November 08, 2007, 10:22:04 AM »

I'm debating on whether to allow FFA gametypes in single player (which brings a host of issues, like populating maps with bots) or to keep it like id's team arena with just team gametypes in single player.

It depends on how big a problem implementation is. I think it must be done if we want the missionpack UI to be the default one.

According to the road plan it is not a goal before 2.0. I personally would prefer it sooner.
Logged

There are nothing offending in my posts.
dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« Reply #11 on: November 08, 2007, 01:43:02 PM »

I think it must be done if we want the missionpack UI to be the default one.

I don't think it _has_ to be done, but it will probably happen.  Also the roadmap is more of a rough guide than anything else, otherwise nothing happens between 0.8 and 1.0.
Logged

dmn_clown
Posts a lot
*

Cakes 1
Posts: 1324


« Reply #12 on: November 08, 2007, 02:03:44 PM »

uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030));
token[0] - 0x030 is just atoi(token[0])

Code:
code/ui/ui_main.c: In function 'MapList_Parse':
code/ui/ui_main.c:4841: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast
code/ui/ui_main.c:4842: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast

atoi(token) is a little bit more friendly.

Quote
(token && token[0] != 0)

Not too big of a deal as gametype 2 also acts as FFA, of course the ui is hardcoded to skip gametypes 2 + 3
« Last Edit: November 08, 2007, 02:14:53 PM by dmn_clown » Logged

iLeft.bye
Member


Cakes 1
Posts: 187



« Reply #13 on: November 08, 2007, 04:45:49 PM »

preferably you should recode those parts
it looks like there is too many hardcoded parts to get the desired behavior with small modifications

ps:
Since I was clueless My approach was theoretical
of course atoi(char) makes no sense
Logged
Pages: [1]
  Print  
 
Jump to: