• 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!

Hook is back

LarryHookins

Buccaneer
Staff member
Storm Modder
Hey guys!

I did a lot of modding for PotC 7 years ago, but ultimately got burned out a bit.

I'd been on Steam playing a space trading game called Drifter, which is good, although simple, when I realized that the archetype for this kind of game is the 17th century sailing ships, so I got Sea Dogs: To Each His Own. While it's a good game, it's ultimately limited in scope. There was no English manual, not even a readme file, so I wrote my own and posted it as a Steam guide. I played a lot, got over 800 hours in the game, but preferred the sandbox style of play to the story line quests. You can play a lot of sandbox in 800 hours. :)

I tried loading PotC, but my 5 year old computer was glitching too much to get a good load. I couldn't even download the newest Build Mod because every time the file would be corrupt. Time for a new computer, eh?

So I bought a new computer. I won't tell you the brand, but if I say I got something near top of the line and you'll think I paid too much, you can figure out what brand it is. I also got saddled with Windows 10, which makes some things easier, but I still prefer Windows 7. I'm putting up with Win 10 for now.

Sea Dogs played well on the new computer, and when I got to a point where I didn't feel like sailing to the next island, I loaded PotC. You'll need MSI Afterburner, or at least the RivaTuner that's included with it, to limit frame rates (I have mine set to my monitor's refresh rate of 60) or the game won't be playable. Currently, after getting everything set up, I only have to run RivaTuner to fix the problem.

The Build Mod downloaded with no problems, and I've been playing it a few hours. The only major problem I discovered so far is that after a few hours, suddenly every save game attempt would crash and produce an empty save. I've already found and fixed that problem, and I'm gonna guess that it's from the original code. Heck, it took less time to find and fix the problem than it did to test for computer problems before I read the error log!

Look in interface.c at the function IGetSaveString. It allocates a string variable, sets it with a function call, then tries to return the string. The problem is, strings are returned by reference, not by value, and if you have a fast computer sometimes the function has already deallocated the string before it can be used by the save function. If you declare that variable (retStr) outside the function, so that it's static and doesn't disappear, you won't have the problem any more. Give it a new name like Save_retStr. You can get away with returning a dynamic variable if you're returning a float or int, but not a string. The fact that this code ever worked is pure chance.

See? I'm back to modding already. :D

To compare PotC with Sea Dogs, SD is better than stock PotC, and certainly prettier, but the modded PotC is the much better game, as it should be with all the work everyone's done on it.

Given that everyone is on super high resolution monitors now, the HUD is going to be too small for many people. I've already started on a mod to scale the HUD, and I'll submit it when I'm happy that it all works right. Got the basic graphics sized right and in the right place, but there's more to it than that; for example, the icon to show time acceleration is in the wrong place and I haven't yet installed my development environment so I can search for it properly. Need to enlarge the spyglass data at the bottom, and the messages that appear on the screen. Maybe you can read them, but my 67 year old eyes aren't up to the task any more.

Gawd, it feels good to be getting my hands dirty with code again. I realized recently that in March I went over 40 years total development experience; I started my professional programming career in the US Army in 1976.

Also, it feels really good to see that "Hook & Hat" tavern sign. :) Probably the best tribute I've ever gotten in all those 40 years. Thanks again to whoever made the sign.

I'll be around.

Hook
 
Holy crap, seeing you back is quite a surprise and you are very welcome indeed, @LarryHookins! :bow

I did take the liberty to move your thread to the POTC Build Mod forum;
otherwise it shows also as News on the main page, which I assume wasn't your intention. Hope you don't mind.... :oops:

I certainly remember all the great things you have done for us and I'm still very grateful for all your hard work back in the Build 13 days.

Look in interface.c at the function IGetSaveString. It allocates a string variable, sets it with a function call, then tries to return the string. The problem is, strings are returned by reference, not by value, and if you have a fast computer sometimes the function has already deallocated the string before it can be used by the save function. If you declare that variable (retStr) outside the function, so that it's static and doesn't disappear, you won't have the problem any more. Give it a new name like Save_retStr. You can get away with returning a dynamic variable if you're returning a float or int, but not a string. The fact that this code ever worked is pure chance.

See? I'm back to modding already. :D
So you're saying you managed to solve the Save issue that has been plaguing us lately? That is GREAT!
Any chance you could post the files that you changed to make that work? :woot
 
Hi, welcome back :).
 
Thanks, Pieter! I'm still learning my way around, had to click on a link in my notifications to find this part of the forum. What can I say, I'm a coder... never said I could figure out a forum. :) I guess we all specialize in *something*.

Ok, until I figure out how to upload the file, it's easier to describe the change... especially since I probably don't have your current source, but whatever was installed with the mod.

In interface/interface.c, the original code looks like this:

string IGetSaveString(string saveName)
{
string retStr;
SendMessage(&GameInterface,"lse",MSG_INTERFACE_GET_SAVE_DATA,saveName,&retStr);
return retStr;
}

It should look like this:

string Save_retStr; // LDH 26Oct16
string IGetSaveString(string saveName)
{
SendMessage(&GameInterface,"lse",MSG_INTERFACE_GET_SAVE_DATA,saveName,&Save_retStr);
return Save_retStr;
}

As long as we're in this file, have a look at this:

int RecalculateHIcon(int curHSize)
{
return makeint(curHSize); // LDH 27Oct16, would return a float if passed one
}

The original code was "return curHSize;", which looks correct and would function in normal C, but the script language is a bit different. If you pass a float, it's not converted to an int, so when you return the value, it's still a float and will cause a message in error.log, even though it seems to work. This is not an essential fix, just a bit of defensive programming.

I've got the interface scaling just about done (I called it HUD scale previously) and I'm happy with the results except for one thing... some of the fonts are a fixed size, like "interface_normal" and "interface_small" and I can't find a list of those values. The fonts in the RESOURCE folder only have a few of these. It might be nice to have an interface guru add a HUD Scale slider to one of the graphics screens, because I've never messed with that part of the code. I can tweak the values for the min/max/default once it's in place, and set the proper variable, but I'm uncertain about writing graphical interface code. Right now it's just a variable set in the globals.c file.

Let me know if you'd prefer me to discuss all this somewhere else... just keep in mind that I'm new here. Well, I've been here before, but I've slept since then. About 2500 times. :D

Hook
 
until I figure out how to upload the file
Should be as easy as dragging it in your forum post. Or use the "Upload a File" button at the bottom of the page. :doff

I probably don't have your current source, but whatever was installed with the mod.
What version are you currently on? I am myself quite behind and only have the 28 July 2016 EXE installed from here:
Mod Release - Build 14 Beta 4.1 WIP [Last Update: 23 sept] | PiratesAhoy!
But I didn't do much of anything yet with the more recent ZIP updates by @Levis.

I've got the interface scaling just about done (I called it HUD scale previously) and I'm happy with the results except for one thing... some of the fonts are a fixed size, like "interface_normal" and "interface_small" and I can't find a list of those values. The fonts in the RESOURCE folder only have a few of these. It might be nice to have an interface guru add a HUD Scale slider to one of the graphics screens, because I've never messed with that part of the code. I can tweak the values for the min/max/default once it's in place, and set the proper variable, but I'm uncertain about writing graphical interface code. Right now it's just a variable set in the globals.c file.
I wonder if @Levis would be able to help a bit with that. I never dabbled much with interfaces myself either.

Let me know if you'd prefer me to discuss all this somewhere else... just keep in mind that I'm new here. Well, I've been here before, but I've slept since then. About 2500 times. :D
If you propose any fixes for bugs currently in the game, you're very welcome to start a new thread here: Build Mod Bug Tracker | PiratesAhoy!
And for improvements/new features, this would be a good place: Build Beta and Brainstorming | PiratesAhoy!
:cheers
 
What a coincidence. I remember talking to you on steam about Sea Dogs to Each his own. You critiqued my review, and I vaguely remember talking about this very forum and this very mod. I had no idea you would get back into it.

This is great :)
 
Thanks, Levis! :D

Redbeard, who are you on Steam? I talked to several people about PotC and the Build Mod.

Hook
 
Update for the historical brass compass. This is a modified version of the one used in Sea Dogs. I've changed the 5 degree marks to be on the 32 compass points. The default one you're using is fine for the cheap compasses, but a good compass should be a bit more useful. I'd prefer to use this compass face for all compasses.

And, just for Pieter who would prefer an actual file with changes, interface.c

Hook
 

Attachments

  • compass2.tga
    256 KB · Views: 360
  • compass2.tga.rar
    38.7 KB · Views: 330
  • interface.c
    62.2 KB · Views: 421
And just to catch up on things...

Hi Levis! Good to meet you and thanks for the welcome. :)

Redbeard: Yeah, we commented on each other's reviews. I had to go back and read them both to remember everything.

Getting reacquainted with PotC has been an interesting experience. I've got about 60 hours of play time so far and I still feel like I'm learning the game. I've got Code::Blocks installed as a development environment, and I recommend it highly, and I'm beginning to find my way around the code again.

Feels GOOD to be back in development. The last code I wrote was 2 years ago, some XML script for aircraft gauges in FSX. Prior to that was the 8 months of 16 hour days on PotC 7 years ago.

And I'm still discovering just how *good* New Horizons is. You guys do good work.

Hook
 
For using your mods Hook, what is your setup? Do you use Levis's folder o' fixes? His thread has a folder added after the latest ZIP, etc. etc. It would be helpful so I know if I can add it to my game, as I don't use Levis's fixes.

Although I suppose a simple compass face wouldn't really conflict.
 
Although I suppose a simple compass face wouldn't really conflict.
That totally depends on whether the relevant files have been modified.
In this case it was interface.c, which is quite a crucial file, so it isn't just "a simple compass face".
I recommend using WinMerge to check the code for any incompatibilities with your own game version.
 
The compass face is stand-alone and is a drop-in replacement. I'd recommend renaming the original file before adding the new one. There should be no conflicts with anything else.

Interface.c changes are basically moving one line a couple of lines up and renaming the variable in 3 places as described in my post. For someone not familiar with coding and editing code files, it's more complicated if there are multiple versions of interface.c. If you are not getting the crash on saving a game, you can live without this fix for a while.

I'm using the stock game as downloaded, the most recent version. I do not use the additional zip file fixes.

Hook
 
Back
Top