Author Topic: [Bug] Game crashes when "profile" is in a select widget  (Read 5026 times)

mRokita

  • Autococker
  • Posts: 598
[Bug] Game crashes when "profile" is in a select widget
« on: April 06, 2015, 12:38:09 PM »
For example, this menu crashes the game:
Quote
widget
   type select
   width 39
   size 15
        xcent -2
        ycent -83
        halign center
   begin pairs
      "Creating the album tree." "Creating the album tree."
      " Reading Dyskografie" " Reading Dyskografie"
      " Reading Pink Floyd - Complete Discography" " Reading Pink Floyd - Complete Discography"
      " Reading The Early Pink Floyd Singles" " Reading The Early Pink Floyd Singles"
      " Reading Star Profile - audio documentary" " Reading Star Profile - audio documentary"
      " Reading Pink Floyd 1975 Tour Comic book" " Reading Pink Floyd 1975 Tour Comic book"
      " Reading Live at Pompei" " Reading Live at Pompei"
      " Reading Cover Art" " Reading Cover Art"
   end

PS.
This bug has wasted 30 minutes of my life.

Clipz

  • Committee Member
  • Autococker
  • Posts: 1497
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #1 on: April 06, 2015, 01:17:41 PM »
If it effected game play I'd say fix it, this is for your own pleasure and doesn't impact the game what so ever. You should code around your own bugs not report them and want jitspoe to look into it. Complete waste of his time.

mRokita

  • Autococker
  • Posts: 598
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #2 on: April 06, 2015, 02:40:37 PM »
If it effected game play I'd say fix it, this is for your own pleasure and doesn't impact the game what so ever. You should code around your own bugs not report them and want jitspoe to look into it. Complete waste of his time.
Well, it's still a bug in the game, not in my script.
My solution is to replace "profile" with "profi1e".
I don't see any way to escape "profile"

xrichardx

  • 68 Carbine
  • Posts: 295
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #3 on: April 06, 2015, 03:02:40 PM »
If this also affects selects with a listsource, it will become funny when someone names his / her server "Profile" making everyone's game crash when they open up the serverlist.

I'll try and search for a fix, maybe I can find something.

mRokita

  • Autococker
  • Posts: 598
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #4 on: April 06, 2015, 03:14:38 PM »
If this also affects selects with a listsource, it will become funny when someone names his / her server "Profile" making everyone's game crash when they open up the serverlist.
No, it does not affect listsource.

xrichardx

  • 68 Carbine
  • Posts: 295
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #5 on: April 06, 2015, 03:45:09 PM »
Ye. The problem is the "file" part. My current status (maybe this helps jitspoe if he wants to fix it): The game will read in all pairs of the select widget correctly in menu.c's select_begin_list called from menu_from_file, but it wont set the read address for COM_Parse to the end of the pairs afterwards, so menu_from_file will parse all pairs again assuming it is parsing widget attributes. When it comes accros the "file" keyword, select_begin_file_list is called which then clears the widgets select_list because there are no files. Still, the widgets select_totalitems will be above 0, causing the game to read from select_list later when it wants to update the subwidgets the select consists of. There, you get the read error.
Possible fixes:
- make the game not modify the list if it already exists in select_begin_file_list (hacky)
- make the game only accept filedir instead of jsut relying on a strstr(token, "file") (hacky)
- make the game correctly continue parsing after the "end" of the pairs of the widget in menu_from_file (I would prefer this). I don't get how COM_Parse decides where to read though, so I can't really post a patch.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #6 on: April 06, 2015, 08:29:01 PM »
Ah, yeah, that's pretty ugly.  I had no idea it was trying to re-parse everything in the select widget list as if it wasn't.  I guess that's what I get for not having any warnings or anything print out when unknown strings are parsed in the menus.  I've fixed it for the next build (and checked it in to source forge).  I had to pass a pointer to a pointer to the select_begin_list function so it would properly advance the original buf pointer.

xrichardx

  • 68 Carbine
  • Posts: 295
Re: [Bug] Game crashes when "profile" is in a select widget
« Reply #7 on: April 07, 2015, 06:07:54 AM »
Since the same crash (interference of the predefined pairs and a filedir) can also occur if a select widget has both set like that:
Code: [Select]
widget
type select
begin pairs
"A" "B" "C" "D" "E" "F"
end
filedir abc
I checked in a fix for that, the game will now always keep the first content specified (in this case, the predefined pairs).