• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Solved Advanced Interface and Flags Code (and much more)

Are you using the blue interface? That used to be buggy. How does the brown interface work?
 
Are you using the blue interface? That used to be buggy. How does the brown interface work?
The thing is that Pirate_KK made his work exclusively on the blue interface. So I HAVE to use that.
Brown.jpg
^ See what I mean? All mismatched. And you can't click on the parts that should be interactive.

So we're going to have to get the blue interface to work properly first and then redo the brown one completely.
Bit unfortunate. Did that once before and then years later we were still finding parts that I had missed out on. :facepalm
 
Now I'm REALLY quite confused. Turns out that my game doesn't always crash when opening the Select Storyline interface.
Sometimes it DOES work. See?
View attachment 10707
But when the interface DOES open, the storyline shown is NOT the Standard one, but the Woodes Rogers one.
One time I managed to scroll all the way to Master & Commander before it crashed, but the other time it crashed before getting to Hornblower.
I don't know WHAT I did, but it's got very unstable results. :facepalm

How strange. I suppose the fact that something works is a good sign, at least.
Do the error logs give you any kind of clues as to what's going wrong?
 
How strange. I suppose the fact that something works is a good sign, at least.
Do the error logs give you any kind of clues as to what's going wrong?
No, they don't. I wish. Before, the game wouldn't run because there were obvious coding errors. And it generated a nice error.log telling me where to look.
Not now though, since I sorted all the obvious ones that the game was willing to report to me.

So I put some trace lines into select_storyline.c to see how far it does get with loading:
Code:
void InitInterface(string iniName)
{
    Trace("Start Loading Interface");
    string attr;
    ref rName; makeref(rName, tmpNames);

    GetLanguageParameters(); // MAXIMUS 30.07.2006
    GameInterface.title = "";

    GameInterface.SHIP.current = 0;
    GameInterface.SHIP.ImagesGroup.t0 = "ICONS";
    GameInterface.SHIP.ImagesGroup.t1 = "SHIPS16";
    GameInterface.SHIP.ImagesGroup.t2 = "SHIPS1";
    GameInterface.SHIP.pic1.str1 = "";
    GameInterface.SHIP.pic1.img1 = "ship back";
    GameInterface.SHIP.pic1.tex1 = 0;
    GameInterface.SHIP.pic1.str2 = "";
    GameInterface.SHIP.pic1.img2 = "";
    GameInterface.SHIP.pic1.tex2 = -1;
    GameInterface.SHIP.ListSize = 1;
    GameInterface.SHIP.NotUsed = 1;

    GameInterface.SELECTPICT.current = 0;
    if (bNewInterface)
        GameInterface.SELECTPICT.ImagesGroup.t0 = "EMPTYFACE_NEW";
    else
        GameInterface.SELECTPICT.ImagesGroup.t0 = "EMPTYFACE";
    GameInterface.SELECTPICT.ImagesGroup.t1 = "ICONS";
    GameInterface.SELECTPICT.ImagesGroup.t2 = "SHIPS16";
    GameInterface.SELECTPICT.ImagesGroup.t3 = "SHIPS1";
    GameInterface.SELECTPICT.BadTex1 = 0;
    GameInterface.SELECTPICT.BadPic1 = "emptyface";
    GameInterface.SELECTPICT.pic1.str1 = "";
    GameInterface.SELECTPICT.pic1.img1 = "";
    GameInterface.SELECTPICT.pic1.tex1 = 0;
    GameInterface.SELECTPICT.pic1.str2 = "";
    GameInterface.SELECTPICT.pic1.img2 = "";
    GameInterface.SELECTPICT.pic1.tex2 = -1;
    GameInterface.SELECTPICT.ListSize = 1;
    GameInterface.SELECTPICT.NotUsed = 1;

    GameInterface.MAP.current = 0;
    GameInterface.MAP.ImagesGroup.t0 = "MAP";
    GameInterface.MAP.pic1.img1 = "map";
    GameInterface.MAP.pic1.tex1 = 0;
    GameInterface.MAP.ListSize = 1;
    GameInterface.MAP.NotUsed = 1;

    for (slno = 0; slno < SKILL_MAX; slno++)
    {
        tmpCharSkills[slno] = 1;
        tmpCharBonusSkills[slno] = 1.0;
    }
    Trace("Skill Things");
    SendMessage(&GameInterface,"ls",MSG_INTERFACE_INIT,iniName);

    slno = FindDefaultStoryline();
    ProfileName = DEFAULT_PROFILE_NAME;

    arstart = GetStorylineStartParams(slno);

    curOutfit = GetModelIndex(arstart.model);
    tmpOutfit = curOutfit;
    curOutfitSex = OUTFITSEX_ANY;
    curOutfitModel = OUTFITMODEL_ANY;
    curOutfitOffType = OUTFITOFFTYPE_ANY;
    curOutfitNation = 0;
    curOutfitNamed = OUTFITNAMED_ANY;
    initialOutfit = -1;
    attr = arstart.model;
    rName.(attr) = "";
    if (CheckAttribute(arstart, "name") == true && arstart.name != "") rName.(attr) = arstart.name;
    if (CheckAttribute(arstart, "lastname") == true && arstart.lastname != "") rName.(attr) = rName.(attr) + " " + arstart.lastname;
    if (rName.(attr) == "") XI_SetRandomName();
Trace("Random Name");
    curShip = -1;
    if (CheckAttribute(arstart, "ship"))
        curShip = GetShipIndex(arstart.ship);
    else
        CharShipName = "";
    tmpShip = curShip;
    curShipClass = -1;
    curShipType = SHIPTYPENAME_ANY;
    curShipModel = -1;
    curShipCannonsQty = -1;
    initialShip = -1;

    shipclass_max = 6;

    zoom_level = 0;
Trace("Start Date");
    CharYear = sti(arstart.date.year);
    CharMonth = sti(arstart.date.month);
    CharDay = sti(arstart.date.day);
    CharHour = sti(arstart.date.hour);
    CharMinute = sti(arstart.date.min);
    CharSecond = sti(arstart.date.sec);
    curPeriod = GetPeriodFromYear(CharYear);
    curPort = -1;
    if (CheckAttribute(arstart, "port")) curPort = FindLocation(arstart.port);
    curLocation = curPort;
    if (CheckAttribute(arstart, "location")) curLocation = FindLocation(arstart.location);
    SetSelectable("SELECTOR1", false);
    SetSelectable("SELECTOR2", false);

    curPlayerType = PLAYER_TYPE_MERCHANT;
    tmpPlayerType = curPlayerType;

    makeref(rShipModel, ShipModels);
Trace("Ship Models");
    idShipDescr = LanguageOpenFile("ShipModels_descriptions.txt");
Trace("Descriptions");
    curWindow = -1;
Trace("curWindow");
    SetWindow(WINDOW_MAIN);
Trace("WINDOW_MAIN");
    CreateString(true, "ScreenTitle", XI_ConvertString("titleSelectStoryline"), FONT_TITLE, COLOR_NORMAL, 320, 5, SCRIPT_ALIGN_CENTER, 1.0);
    CreateString(true, "StorylineTitle", GetStorylineTitle(slno), FONT_NORMAL, COLOR_NORMAL, 320, 84, SCRIPT_ALIGN_CENTER, 1.0);
    CreateString(true, "lblProfile", TranslateString("", "Profile") + ":", FONT_NORMAL, COLOR_NORMAL, 200, 245, SCRIPT_ALIGN_LEFT, 0.7);
    CreateString(true, "StartDate", "", FONT_NORMAL, COLOR_NORMAL, 200, 270, SCRIPT_ALIGN_LEFT, 0.7);
    CreateString(true, "StartLocation", TranslateString("", "unknown"), FONT_NORMAL, COLOR_NORMAL, 320, 292, SCRIPT_ALIGN_CENTER, 0.7);
    CreateString(true, "LblNation", TranslateString("", "Nation") + ":", FONT_NORMAL, COLOR_NORMAL, 200, 318, SCRIPT_ALIGN_LEFT, 0.7);
    CreateString(true, "LblFlags", TranslateString("", "Flags") + ":", FONT_NORMAL, COLOR_NORMAL, 320, 318, SCRIPT_ALIGN_LEFT, 0.7);
    CreateString(true, "Difficulty", TranslateString("", GetDifficultyNameFromListNumber(CharDifficulty)), FONT_NORMAL, COLOR_NORMAL, 270, 344, SCRIPT_ALIGN_CENTER, 0.7);
    CreateString(true, "PlayerType", TranslateString("", GetPlayerTypeName(curPlayerType)), FONT_NORMAL, COLOR_NORMAL, 395, 344, SCRIPT_ALIGN_CENTER, 0.7);
Trace("Create String Finished");
    SetFormatedText("INFO_TEXT", GetStorylineDescription(slno));
    SendMessage(&GameInterface,"lsl",MSG_INTERFACE_MSG_TO_NODE,"INFO_TEXT",5);
Trace("Start Create Text Box");
    CreateTextbox(true, "Profile", "PROFILE_TEXTBOX", "PROFILE_BORDER", "", "", 345, 240, 1.0);
    CreateTextbox(true, "CharacterName", "CHARNAME_TEXTBOX", "BOX1", "RAMKA1", "", 124, 375, 1.0);
    CreateTextbox(true, "ShipName", "SHIPNAME_TEXTBOX", "BOX2", "RAMKA2", "", 516, 375, 1.0);
    CreateTextbox(false, "ShipClass", "SHIPCLASS_TEXTBOX", "BOX4", "RAMKA4", "", 245, 306, 0.8);
    SetTextboxNumeric("ShipClass");
    SetTextboxMinMax("ShipClass", shipclass_max, MIN_CLASS);
    CreateTextbox(false, "CannonsQuantity", "SHIPCANNONSQTY_TEXTBOX", "BOX5", "RAMKA5", "", 500, 306, 0.8);
    SetTextboxNumeric("CannonsQuantity");
    SetTextboxMinMax("CannonsQuantity", 0, 200);
    CreateTextbox(false, "SearchText", "SEARCH_TEXTBOX", "BOX3", "RAMKA3", "", 500, 368, 0.8);
Trace("Storyline Quantity");
    if (GetStorylinesQuantity() == 1) {
        SetNodeUsing("STORYLINE", false);
        SetNodeUsing("RAMKA", true);
        SetNodeUsing("BOX", true);
    }

    slno = 0;
    ChangeStoryline(false);

    SetEventHandler("InterfaceBreak","ProcessCancelExit",0);
    SetEventHandler("exitCancel","ProcessCancelExit",0);
    SetEventHandler("ievnt_command","ProcCommand",0);
    SetEventHandler("IEvnt_MouseClick", "IProcMouseClick", 0);
    SetEventHandler("UpStep", "DoUpStep", 0);
    SetEventHandler("DownStep", "DoDownStep", 0);
    SetEventHandler("StartGame", "GameStart", 0);
    Trace("Finish Loading Interface");
}
Turns out that IF it crashes upon loading the interface, it does so on the SetWindow(WINDOW_MAIN); line. I don't know what that does though or why that only causes crashes sometimes.
If I comment out that line, it works, but part of the interface is missing.

Also, WHY is the Standard storyline not showing in the interface anymore? Whenever it does manage to load, it skips straight to Woodes Rogers.
Scrolling left crashes the game. Scrolling to the right works until Master & Commander and then the game crashes anyway.

The HMS_Bellona is not showing her interface screenshot in the Select Storyline, even though the code for that looks perfectly correct and it does work for the other ships.
I wonder if possibly the game is just having to load too much stuff from RESOURCE\INI . I remember ages ago that when we added too many sounds there, some were starting to drop out.
Maybe now other things are dropping out?
 
The HMS_Bellona is not showing her interface screenshot in the Select Storyline, even though the code for that looks perfectly correct and it does work for the other ships.
I wonder if possibly the game is just having to load too much stuff from RESOURCE\INI . I remember ages ago that when we added too many sounds there, some were starting to drop out.
Maybe now other things are dropping out?
That appears to be CONFIRMED! I set all troublesome storylines' start.ship to "BarqueHeavy", which is comfortably part of [SHIPS1].
Now I managed to scroll freely between every single storyline without any apparent problems.

So it seems now we know where the problem comes from: we're literally running into the game's ceiling.
Only solution I can think of: Remove stuff so that we DON'T run into the ceiling. So how are we going to do that, then? :facepalm

A lot of the sounds have been moved from PROGRAM\sound\ALIAS back to RESOURCE\INI\ALIASES .
We may have to see about moving as much as possible back again.
Any 3D sounds must be defined in the INI folder, otherwise they don't work. But stereo files can go into the PROGRAM folder.
This is sound_alias.ini seems relevant:
Code:
; ===== this insect file should go last so we can tell if we've exceeded the number of alias names.  system.log will have errors on this name if we do
[nightinsects]
minDistance = 0.30
maxDistance = 3.0
volume = 0.3
name = NATURE\cricket.wav
name = NATURE\cricket2.wav
That is a note by Hook from when he was working on fixing the sound issue we were having.

I know that ALL files in the INI folder are loaded, even if they're not needed. Add a lot of copies of the same file and we'd have trouble.
So we need to remove any files that aren't used. Does anyone know anything that we could get rid of?

What I don't know is if the game sees any difference between picture and sound entries in the INI folder.
I suspect that it doesn't, because apart from the folder names, how would the code be able to tell the difference?

Could we get rid of the Animated interfaces? Either by setting them as always on or by getting rid of them altogether?
That might help at least a little bit?
 
That appears to be CONFIRMED! I set all troublesome storylines' start.ship to "BarqueHeavy", which is comfortably part of [SHIPS1].
Now I managed to scroll freely between every single storyline without any apparent problems.

So it seems now we know where the problem comes from: we're literally running into the game's ceiling.
Wow. That's not good. :8q

Here's a thought: ensuring all the start ships use just one of the four interface textures seems to have fixed the problem, so what if we rearranged the interface textures so that all the correct start ships use only SHIPS1?
It would be a fiddly process, but certainly doable. Loading all of those massive textures can't be good for performance in any case.
 
Here's a thought: ensuring all the start ships use just one of the four interface textures seems to have fixed the problem, so what if we rearranged the interface textures so that all the correct start ships use only SHIPS1?
It would be a fiddly process, but certainly doable. Loading all of those massive textures can't be good for performance in any case.
I'm afraid that would just move the problem to whenever a ship is used that does use one of the other textures.
Will have to do some experimenting to see what does and doesn't affect the game's INI affairs. It seems most peculiar. :facepalm
 
Turns out it isn't as bad as I thought. Why the game was crashing, I do not know.
However, now that I've fixed all Pirate_KK's interface files to fully support the Interface Screenshots Mod, it seems to behave a whole lot better now.
It's not perfect, but now I do manage to use the menu (without those misplaced textures, of course) AND start a new game with the Standard storyline.
 

Attachments

  • SelectStorylineFixed.jpg
    SelectStorylineFixed.jpg
    242.3 KB · Views: 93
So it's no longer crashing, all textures are showing, AND it seems to function as expected? That's got to be a good sign, at least!
What problems are you still facing?
 
Still a lot.

- Pirate_KK rewrote the dialog system, but with all our storyline work, we're not going to be able to accommodate that. So I have to restore it to "Pre-KK" state.
- Still have to make sure all storyline and interface files contain all Post Build 14 Beta 1 code changes.
- Missing textures; waiting for Pirate_KK to send them again.
- Possible compatibility issues and non-obvious merging issues (will need some serious testing by other people eventually)
- Pirate_KK's code is in many instances not yet finished and needs further work.

I'll try to sort out what further merging I can next week and hopefully I'll have the missing files then too.
Once I'm done, I'll upload a test version so people can try to find out whatever issues there are with the combined game version.
We're still making progress, at least. But we're a looong way off from having it fully ready for a stable Build 14 Beta 2.4.

In fact, I'm considering just releasing Build 14 Beta 2.4 pretty much as-is, once your Corvette-work is completed plus whatever fixes we manage to come up with.
Then we can leave the KK code for Build 14 Beta 2.5. At least then we'll KNOW Beta 2.4 is more stable and less buggy than the previous release. :wp
 
So that's quite a lot, then. You're probably right that waiting to release this stuff until Beta 2.5 would be better.

What's so different about the dialogue system, out of interest?
 
Good news! Pirate_KK sent me his latest files as well as the missing texture files. So we'll be able to continue with the merging thing again!

I'll focus first on getting the next release done as well as possible. But once that is out of the way, we'll have some good new stuff to look forward to.
Here are some screenshots from my currently merged version:
CharacterSkills.jpg CharacterOptions.jpg Officers.jpg NationRelations.jpg
 
And the one we've all been waiting for: Customizable Select Storyline Interface!

SelectStoryline.jpg SelectCharacter.jpg SelectShip.jpg SelectNation.jpg SelectPersonalFlag.jpg SelectPirateFlag.jpg SelectPlayerType.jpg SelectStartingLocation.jpg

Not yet working: Select Starting Date and Select Starting Location. But maybe with Pirate_KK's new files? Haven't looked at the code of those yet.
 
Someone please give PirateKK a medal... he bloody well deserves it for all this stuff! :woot
 
Indeed he's been doing a brilliant job at it! There were still several distinct rough edges that are not apparent from those screenshot,
but he may have fixed those a bit further by now and we'll deal with those when we get to them anyway.
In the meantime... I think we can afford a bit of excitement! :cheeky
 
I asked Pirate_KK if he managed to get the Starting Date Selection working yet, but he didn't do that yet.
He is willing to try to work on it over the next few weekends though. With a bit of luck, that'll work out nicely for... Build 14 Beta 3, I think? :wp
 
Back
Top