Author Topic: Barracks bug fix (old plr files)  (Read 4150 times)

0 Members and 1 Guest are viewing this topic.

Offline el84

  • 23
Barracks bug fix (old plr files)
Barracks bug biting you? You know, you have an old plr file that causes FS2 to crash if you try to change pilots? Or you have been messing around with mods, and now your favorite plr file seems to be corrupt? Here’s the scoop:

In Ship.h:
#define   MAX_SHIP_TYPES   130

The ships.tbl is parsed in Ship.cpp, and the global int Num_ship_types is set equal to the number of ships defined in ships.tbl. So far, no problem.

In Barracks.cpp, the function barracks_init_stats() builds an array of strings to be displayed when you view your stats. There are 20 lines of miscellaneous stats, followed by one line for each type of ship you have killed. Problem is this define near the top of Barracks.cpp:
#define   NUM_STAT_LINES   85

Only 65 lines of text are reserved to display kills-by-ship-type. Kill that 66th ship type and FS2 crashes when you try going to the Barracks screen.

The fix is simple. Increase NUM_STAT_LINES:
#define   NUM_STAT_LINES   150

Better yet, do this just in case someone increases the ship types limit:
#define   NUM_STAT_LINES   MAX_SHIP_TYPES + 20

If it does not compile, try adding this line to the other #include statements in Barracks.cpp:
#include “Ship.h”


For those that can’t yet compile the code, and for those that still like playing on PXO, I wrote a small utility to edit a plr file (sorry cheaters, you can only delete kills-by-ship-type, not add ;) ). I’ll release it this weekend.

 

Offline Blue Lion

  • Star Shatterer
  • 210
Barracks bug fix (old plr files)
Yea, bothers me when I try to switch pilots and it crashes on me, that would be awesome

 

Offline el84

  • 23
Barracks bug fix (old plr files)
I think the program is ready for people to try.

http://www.iepd.com/el84/FS2PlrFileRepair_v0.2.zip

It's a 1.4Meg download. Most of that is the Borland VCL dll.

Use at your own risk, backup your plr files first, yada yada yada.

The utility supports custom ships tables. Just drop a copy of your ships.tbl into the same directory as PlrFileRepair.exe and it will extract the ship-type names. More info is available under the Help menu.

Please use this thread to report bugs or suggest improvements. I'd rather not provide support through email.

Enjoy!

 

Offline Cetanu

  • 27
    • http://165thbdhr.com/
Barracks bug fix (old plr files)
Mmm, I tried your tool (after I got borlndmm.dll and cc3250mt.dll elsewhere) but a doubleclick brought no delete dialogbox.
Work is the curse of the drinking class
Keeper of BDHR's Holy Grail of Beer

Valid PXO/F2NETD multiplayer missions - mirrors: 1,2
Additional valid F2NETD multiplayer missions - mirrors: 1,2
Voicefiles for these missions - mirrors: 1,2

 

Offline el84

  • 23
Barracks bug fix (old plr files)
Sorry Cet. Borland CBuilder drives me crazy sometimes.

I should say: deploying programs created with BCB5 drives me crazy. I paid (um, my company paid) about $800 for BCB5 Pro, and it came with a castrated version of Install Shield Express. One would think that a company trying to compete in the compiler market would provide tools that actually work. I like the BCB IDE – I find VCL easier for rapid development compared to MFC. But that’s probably because I am much more familiar with VCL than MFC. Oh well.

I'll fix the installer this afternoon to include the two missing dlls.

About the missing dialog: did you double click on a ship type that had kills? I figured it did not make sense to display the confirm dialog if the user dbl-clicked on a ship type that had no kills. There'd be nothing to delete.

But I'll see if I can recreate the problem.

 

Offline Cetanu

  • 27
    • http://165thbdhr.com/
Barracks bug fix (old plr files)
Thx, that was the hint - I tried to delete the empties (thought they use up space too) but if only the kills count...
To bad its no permanent solution for a PXO player, the kills come back when you loggin to PXO, at least I can use your tool to change the squad logo without crashing ;)
Work is the curse of the drinking class
Keeper of BDHR's Holy Grail of Beer

Valid PXO/F2NETD multiplayer missions - mirrors: 1,2
Additional valid F2NETD multiplayer missions - mirrors: 1,2
Voicefiles for these missions - mirrors: 1,2

 

Offline Cetanu

  • 27
    • http://165thbdhr.com/
Barracks bug fix (old plr files)
how can I delete my posts? ;)
Work is the curse of the drinking class
Keeper of BDHR's Holy Grail of Beer

Valid PXO/F2NETD multiplayer missions - mirrors: 1,2
Additional valid F2NETD multiplayer missions - mirrors: 1,2
Voicefiles for these missions - mirrors: 1,2

 

Offline el84

  • 23
Barracks bug fix (old plr files)
Doh! I didn't think that PXO would save a copy and restore the stats. Crap.

On the bright side, I did learn alot about the internals of FS2 while making this.

Anyway, I rebuilt the project so it does not require the Borland dlls (static linked the required libraries). The install file is much smaller, weighing in at about 900k:

http://www.iepd.com/el84/FS2PlrFileRepair_v0.3.zip

 
Barracks bug fix (old plr files)
I noiticed that mine only crashes on pilots over the rank of commander
Watching from the background since 17 April 2002.

 

Offline DTP

  • ImPortant Coder
  • 28
    • http://www.c4-group.dk
Re: Barracks bug fix (old plr files)
Quote
Originally posted by el84

Better yet, do this just in case someone increases the ship types limit:
#define   NUM_STAT_LINES   MAX_SHIP_TYPES + 20


If you do this and lets say somebody set max_ship_types to 240, FS2. will CRASH when you exit via jump, as MAX_PACKETS are reached ´MAX_PACKETS are defined to 512, and then you are starting to mingle with the net-code. not a good idea.

max_ship_types should be safely set to 200 MAX. TESTED this to be a safe limit.
VBB member; reg aug 1999; total posts 600.
War is a lion, on whos back you fall, never to get up.
Think big. Invade Space.

 

Offline el84

  • 23
Barracks bug fix (old plr files)
DTP, I disagree.

NUM_STAT_LINES has no effect on net code. Its definition does not escape beyond the scope of Barracks.cpp. Specifically, NUM_STAT_LINES determines the dimension of arrays Stat_labels[][] and Stats[][]. These arrays are unknown outside of Barracks.cpp. See lines 336 and 337 in Barracks.cpp.

The fact that you are modifying MAX_SHIP_TYPES supports my suggestion that NUM_STAT_LINES not be defined as a fixed number, but should be determined at compile time based on the definition of MAX_SHIP_TYPES.
« Last Edit: May 13, 2002, 01:26:56 am by 727 »

 

Offline DTP

  • ImPortant Coder
  • 28
    • http://www.c4-group.dk
Barracks bug fix (old plr files)
doh, i Should have written this more clearly.:o

I understand that num_stats_lines dont affect max_packets!.

what i meant was if ppl start to modify the MAX_SHIP_TYPES that they should not pass 200 unless they want to rewrite a whole lot of stats read and send functions because of max_packet_size.

I know, been there, done that.

if max_packet_size => ~240+- 20

then FS2 will crash, because the packet trying to be send will be larger than max_packet_size.

A larger max_packet_size seems not to  solve this either as max_packet_size is only used for assertion in the add data function causing the crash. :)
VBB member; reg aug 1999; total posts 600.
War is a lion, on whos back you fall, never to get up.
Think big. Invade Space.