Two things to try:
1. Open PROGRAM\SEA_AI\AIGroup.c and set:
Code:
#define MAX_SHIP_GROUPS 64
to a higher number, such as 128 or so and see if that helps.
2. Open PROGRAM\CCCdirectsail.c and find:
Code:
string groupname = "Directenc"+rand(100);
Replace with:
Code:
// PB -->
// groupname = "Directenc"+rand(100);
if(CheckAttribute(rPlayer, "DirectSailEncounterGroup")) rPlayer.DirectSailEncounterGroup = sti(rPlayer.DirectSailEncounterGroup) + 1;
else rPlayer.DirectSailEncounterGroup = 1;
if(rPlayer.DirectSailEncounterGroup > 20) rPlayer.DirectSailEncounterGroup = 1;
groupname = "Directenc" + sti(rPlayer.DirectSailEncounterGroup);
// PB <--
This should reuse the same 20 groups for DirectSail encounters and hopefully prevent us from going over the max.
This is not tested, but you can try and see what gives.
Done. I set the max ships to 248 for good measure. Now to go play!
EDIT: Didn't get anywhere. There is a problem with the last line of your addition in CCCdirectsail.c
COMPILE ERROR - file: CCCdirectsail.c; line: 1393
Undeclared identifier: groupname
EDIT2: I got a ctd with the error
RUNTIME ERROR - file: sea_ai\AIGroup.c; line: 106
invalid index 64 [size:64]
RUNTIME ERROR - file: sea_ai\AIGroup.c; line: 106
function 'Group_FindGroup' stack error
RUNTIME ERROR - file: sea_ai\AIGroup.c; line: 29
Using reference variable without initializing
I don't have the knowledge to fix this.
Moved this from another post to this topic. Or would it be better to discuss technical in another post, or the bugtracker?
Most of the code creating Directsail encounters is copied from the original code that loads the mapencounters to seaview.
IIRC this is supposed to work like this:
Step 1
string groupname = "Directenc"+rand(100);chooses a random name for the group of ships that you will encounter next
Step 2, some lines down
rGroup = Group_GetGroupByIndex(Group_CreateGroup(groupname));creates a shipgroup with that name. The following line
Group_DeleteAtEnd(groupname);should delete the group after you leave this scene, so there SHOULD be no problems with too many encounter groups (but who knows).
To test your assumption that "Directenc"+rand(100) is the culprit you could change it first to "Directenc"+rand(2) and then -after testing if this causes more or less crashes - to "Directenc"+rand(10000) and to "Directenc" without any number. If your assumption is right you should notice a difference.
To get more debug data add the line
Trace("Directsail encounter groupname: " + groupname );so that the groupnames will be logged in the debugfiles. Then you can look if a certain groupname -or sequence of groupnames- occurs before CTDs.
But I don't think the number in rand(100) vs the maximum number of AI groups is a problem, for three reasons:
1. As said, the group should be deleted by Group_DeleteAtEnd, so there should never more than one Directenc... group.
2. rand(100) doesn't count upwards till you get over the 64 AIgrouplimit. Instead it picks random numbers, like 65, 3, 98, 18, 3again...
3. string groupname creates a TEXTstring, like "Directenc65". For the program that is a word like "DirectencJones", not a number.
So I don't see any number there that could violate any limit like the AIgrouplimit.
It just MIGHT be possible that the double use of the same name causes problems. That can be checked easily if you use always the same name:
string groupname = "Directenc";If doublenames are a problem this should crash at the second encounter.
But judging from the posted errorlogs I'd also say that somehow the directsailencounters cause thie problem. To disable them outcomment the line
// DirectEncounter( stf(Login.PlayerGroup.ay) );
in the function SeaLogin(ref Login) in SeaAI\sea.c.
And have you tried Pieter's proposal No.1 only, without adding the second fix:
1. Open PROGRAM\SEA_AI\AIGroup.c and set:
Code:
#define MAX_SHIP_GROUPS 64
to a higher number, such as 128 or so and see if that helps.