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

Tutorial Tool to Create Ships Init Overview

Hotshot

Freebooter
Storm Modder
I've coded myself a WebApp to display all ships with their stats:
PotC - Ship Data Extraction Tool

This app reads your "Ships_init.c" and "common.ini" from you game version (default or modded), extracts the information, saves it to a file and displays it in a table.

You can then view ships across several files (i.e. versions), set a specific filter (like display only class 1), hide specific columns (like speedrate or turnrate) and set a primary (left mouse click) and secondary (right mouse click) sorting column, where ascending/descending can be switched by clicking the column again.

You can add ships to be compared (even across multiple files) -> these rows will be highlighted blueish and will be shown in the comparison menu docked to the right side of the screen.
This comparison can then be saved for later access by copying the presented URL.

More info can be found in the included "Help" or "Differences in ingame data" tooltips!


Latest tool version (23.06.2016)
 

Attachments

  • PotC-Ships.zip
    102.9 KB · Views: 578
Last edited by a moderator:
@Hotshot: I've hyjacked your posts to create a new thread about your Ship Overview Tool here.
Definitely seems like something deserving of its own discussion spot! :cheers

@Armada, @Thagarr and @Mere_Mortal should all find this quite interesting I think. :doff
 
Code:
Fatal error: Call to undefined function: array_fill_keys() in [localhost]\index.php on line 297
:unsure

Oh wait, I think my Apache is “a bit out of date”. Never mind, I’ll look at it tomorrow. :rolleyes:
 
Last edited:
Hey, this thing is rather swank. I still haven’t bothered to update my local server, as has been the case for the past two years, but luckily my web host runs at PHP5 so I can have a play with it. :cheeky

Just thinking... this could really easily be dumped into a database. I suppose the data file which the code looks at or can even create, pretty much is one, but I mean something with a front-end like MySQL. The way your app works and looks it actually does come across like a database script of sorts. It could even be used to edit the data while being able to compare against similar ships at the same time.

I’m a bit curious, though... how much validation is taking place in respect of the file upload? At a glance it doesn’t really look very safe to me.
 
What ways would there be to integrate it with the Wiki?

Other very interesting filters are the nation and period ones.
 
Are wiki pages based on text files anyway? If so then it probably wouldn’t be too difficult at all. So instead of dumping an extensive list of all the ships, you’d just grab the details for whichever ship the page is on.

I was wondering if it might be a good idea to put a string variable onto every ship with their standard English name. It probably wouldn’t be widely used by the code since stuff can ideally be translated, but it would be great for reference and dumping the stats like this tool does. So rather than the tool listing items by their ID, it would instead display their full name.

As for the security side of things, I’ve noticed that the import function bails on an entry if there a non-alphanumerical characters so that’s really good. However, since somebody can dictate the file extension by means of the “description”, I do think it would be a very good idea to either strip the file extension if present or just plonk a “.txt” on the end of it so that the server always reads it as plain text. By rights, nobody should ever be able to upload a file to a server with an executable extension such PHP - it’s completely barmy to allow that.
 
Last edited:
I was wondering if it might be a good idea to put a string variable onto every ship with their standard English name. It probably wouldn’t be widely used by the code since stuff can ideally be translated, but it would be great for reference and dumping the stats like this tool does. So rather than the tool listing items by their ID, it would instead display their full name.
That's what the SName attribute is for. That is the one that gets translated to a "readable" name using common.ini .
 
Of course, but that’s another file. So the tool would either need to look at that as well or the text strings be appended to ships_init before uploading it so that it can link the variables.
 
Since the ship's real description is in "common.ini", the tool really ought to look there. That way, anyone who subsequently adds a new ship doesn't need to worry about putting the same name into two locations.

Another good place to check might be "ShipModels_descriptions.txt", which holds the descriptions you see in the shipyards.
 
I've updated my code to include periods: http://www.stumpfl.at.tf/PotC-Ships
That is really cool! Thanks. :woot

Is that "Class" the value taken directly from ships_init.c?
In the Build 14 Beta versions, we make use of a "Tier" system that is related directly to the maximum number of crew.
That overrides the "refShip.class" attribute through some code at the bottom of ships_init.c .
So those values noted in the file itself may differ from the value you would see in the game.
 
Sry for not posting a while... work&live^^

I've hyjacked your posts to create a new thread about your Ship Overview Tool here.
Definitely seems like something deserving of its own discussion spot!
Sure, thanks!

I suppose the data file which the code looks at or can even create, pretty much is one, but I mean something with a front-end like MySQL.
I've never used a real database; mostly because I never needed to^^ But sure it could work with a DB easy enough.
One would just need to change the "Save" & "Load" function from exporting to a file to saving the array (it's nothing more) into database tables...
But it's more easily copied as it is!

It could even be used to edit the data while being able to compare against similar ships at the same time.
What data would you like to edit? 'cause comparing is already possible...

how much validation is taking place in respect of the file upload? At a glance it doesn’t really look very safe to me
There is NO validation what so ever (that's why I disabled the upload for my personal hosted site). But good point; I'll add something that not just any file can be uploaded...

What ways would there be to integrate it with the Wiki?
Hm... I don't know about your wiki (or any other for that matter^^) -> it'd probably be best to not totally integrate it but host it on the same webhoster and linking to it (or adding it via iframe).
I'd recommend editing the style.css so it fits to the wiki (and your liking ;-))

Other very interesting filters are the nation and period ones.
I've to think about how the nation could be added...

So rather than the tool listing items by their ID, it would instead display their full name.
I really like that idea! :)

By rights, nobody should ever be able to upload a file to a server with an executable extension such PHP - it’s completely barmy to allow that.
True! This is for now coded for "offline" use ;-) But I'm looking into changing that...

Since the ship's real description is in "common.ini", the tool really ought to look there. That way, anyone who subsequently adds a new ship doesn't need to worry about putting the same name into two locations.
Another good place to check might be "ShipModels_descriptions.txt", which holds the descriptions you see in the shipyards.
Good info, thanks! I'll look into it!

Is that "Class" the value taken directly from ships_init.c?
That's correct.
So this "class" variable is basically not in use anymore? One can just deduct the class from the number of crew?
 
Hm... I don't know about your wiki (or any other for that matter^^) -> it'd probably be best to not totally integrate it but host it on the same webhoster and linking to it (or adding it via iframe).
I'd recommend editing the style.css so it fits to the wiki (and your liking ;-))
Indeed just a link to your page should probably do the trick.
I like easy solutions. ;)

I've to think about how the nation could be added...
Same way as period? It works pretty much the same in the game as periods do.

So this "class" variable is basically not in use anymore? One can just deduct the class from the number of crew?
Correct. You can find the Tier categorizations at the bottom of ships_init.c .
 
I was just about to adding the real ship names, but there is a little problem... the "common_mod.ini" doesn't seem to have the actual names from "ships_init.c"!? (GoldenHind, Tartane2, FR_Dilligente, LuggerVML, ...)
I would need something like the "ShipModels_descriptions.txt": here the names are the same and it would be possible to match those to the existing data and add the text. But these descriptions aren't really useful in my opinion; the real names (as displayed in-game) would be very much so!

-> any pointer on where to find the file that correlates between the "ID" from ships_init.c to the actual name?
 
In ships_init.c, the refShip.Sname attribute is what refers to the names shown in common.ini . :doff
 
Back
Top