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

Fixed Reinit Deletes Map Items

okay, so tried it, changed codes somewhere, reverted it back to normal trying reinit..

changing some codes causes this, while others don't. changing lines in ships_init, and island_init causes this, but changing lines in items_init doesn't.

however if you do want to change lines in ships and islands, you have to start a new game to prevent this issue.
 
in islands_init, i change the contraband in isla muelle, in ships, i changed the carry weight of a ship i have.
 
I've included several screenshots as well as two savegames:
  • 1st save from "before" the fix; items still in inventory and everything's fine ("inventory/maps" and "looting/exchanging items")
  • 2nd save after pressing F11 and getting rid of the Indian weapons: inventory looks fine at first, but there is 1 empty "item/placeholder" under "Items" ( Inventory - Items.jpg ) and "Quest-Items" (Inventory - Quest.jpg ) & there are no maps any longer (Inventory - Maps.jpg )! And there are those... openings in my inventory when exchangin/looting (Inventory - Looting_Chest 1.jpg | Inventory - Looting_Chest 2.jpg
 

Attachments

  • Saves.7z
    684.7 KB · Views: 86
Last edited by a moderator:
@Hotshot: I've copied and edited your post to fit in with this thread. I think that is probably the same issue.
As I said, I couldn't replicate it when I tried it last time. But now that the issue is reopened, I'll be sure to look into it again. :doff

In the meantime, do you make any use of non-default modpack settings?
It may be possible that custom settings can have unintended side-effects.
 
@Hotshot: Yep, it seems I could indeed replicate the problem this time.

Code:
ITEMS: Store opiumlist at place 0 for recovery after init
ITEMS: Restore opiumlist at place 808 in the itemsarray
[...]
WARNING! Can`t find item ID = map value: 1
WARNING! Can`t find item ID = mapoxbay value: 1
WARNING! Can`t find item ID = mapcayman value: 1
WARNING! Can`t find item ID = mapdouwesen value: 1
WARNING! Can`t find item ID = mapfalaisedefleur value: 1
WARNING! Can`t find item ID = mapguadeloupe value: 1
WARNING! Can`t find item ID = mapislamuelle value: 1
WARNING! Can`t find item ID = mapquebradascostillas value: 1
WARNING! Can`t find item ID = mapredmond value: 1
WARNING! Can`t find item ID = mapturks value: 1
WARNING! Can`t find item ID = mapredmond_dungeon value: 1
WARNING! Can`t find item ID = mapoxbay_dungeon value: 1
WARNING! Can`t find item ID = mapkhaelroa_templeground value: 1
WARNING! Can`t find item ID = mapkhaelroa value: 1
WARNING! Can`t find item ID = mapantigua value: 1
WARNING! Can`t find item ID = maphispaniola value: 1
WARNING! Can`t find item ID = mapsaintmartin value: 1
WARNING! Can`t find item ID = maparuba value: 1
WARNING! Can`t find item ID = mapeleuthera value: 1
WARNING! Can`t find item ID = mapdouwesen_cave value: 1
WARNING! Can`t find item ID = mapconceicao value: 1
WARNING! Can`t find item ID = mapkhaelroa_templeupper value: 1
WARNING! Can`t find item ID = mapoxbay_cave value: 1
WARNING! Can`t find item ID = mapcuracao value: 1
WARNING! Can`t find item ID = mapcuba value: 1
WARNING! Can`t find item ID = smuggling_papers value: 1
WARNING! Can`t find item ID = indian13
items =
  medical1 = 2
  indian13 = 1
  medical2 = 1
  pistolgrapes = 1
money = 0
 
In PROGRAM\ITEMS\initItems.c find:
Code:
n = RestoreStoredItems(n); // Added by Levis
Replace with
Code:
//  n = RestoreStoredItems(n); // Added by Levis
That at least disables the bug by disabling the code responsible for it.
Not yet a proper fix though.
 
I think I managed to fix this properly now. Save attached to your PROGRAM\ITEMS folder.

This happened ONLY if you had one of "Levis' persistent items", such as the "Opium List" in your inventory.
That also explains why I couldn't replicate it on a "New Game": At game start you wouldn't actually have any such items yet.

The "restore" function that Levis wrote to reset those items messed up the item array.
I have now rewritten that section to avoid the problem:
Code:
int  RestoreStoredItems(int n)
{
   int numstored = GetAttributesNum(StoredItems);
   aref olditm, itm;
   int oldidx = -1;
   for(int i=0;i<numstored;i++)
   {
     makearef(olditm,StoredItems.(i));
     oldidx = GetItemIndex(olditm.id);
     if(oldidx < 0) // PB: If item not yet initialized
     {
       oldidx = n;
       n++;
     }
     makearef(itm,Items[oldidx]);
     trace("ITEMS: Restore "+olditm.id+" at place "+oldidx+" in the itemsarray");
     CopyAttributes(itm,olditm);
     itm.index = oldidx; // PB: Reset index
   }
   DeleteAttribute(StoredItems, ""); // PB: was DeleteClass(StoredItems);
   return n;
}
As far as I can tell, this fixes it properly and I have been unable to replicate the bug since.

This should be useful for everyone, but of course especially @gianflores13 and @Hotshot who have been running into this problem. :facepalm
 

Attachments

  • initItems.c
    312.1 KB · Views: 101
do you make any use of non-default modpack settings
You mean changes to the InternalSettings.h? Yep, there are changes:
  • #define REALISTIC_SHIP_INERTIA 1
  • #define SHORE_DANGER_ALARM 1
  • #define NAVIGATION_EQUIPMENT 1
  • #define ENABLE_LIMITED_SHIPCLASS 1
  • #define CANNOT_RELOAD_WHILE_FIGHTING 2
  • #define ITEM_REALISM 1
  • #define ENABLE_SKILLUP_IFZERO 1
  • #define PERK_MULTIPLIER 0
  • #define ALLOW_LOCKED_PERKS 0
  • #define SIDESTEP_DIST_LEFT 0.07
  • #define SIDESTEP_DIST_RIGHT 0.07
  • #define SIDESTEP_DELAY 9
  • #define START_DIFF_SHIPCAP 1 (although I'm not sure if this one works: Pirates seem to use only Class 5 ships (Sloop of War for instance) If I'm not mistaken, their "maximum class" is 3, right? Shouldn't they be coming at me with those?
  • #define EXTRA_HIT_CHECK 0
  • #define SHIPYARD_CHANCE_CLASS 0
  • #define BLADEDAMAGE_ENABLED 0
  • #define AUTOLOOT_BOARDINGS 1
  • #define SHOWHP_PLAYER 1
  • #define USE_PARTICLES_CANNONS 2
  • #define SIDESTEP_ENABLED 1
 
You mean changes to the InternalSettings.h?
Thanks for the response. Though in the end it turned out it was unrelated to any modpack settings and was an actual general bug. :yes

#define START_DIFF_SHIPCAP 1 (although I'm not sure if this one works: Pirates seem to use only Class 5 ships (Sloop of War for instance) If I'm not mistaken, their "maximum class" is 3, right? Shouldn't they be coming at me with those?
With that setting, the Tier of the enemy ships is related to your own. So Pirates would only get bigger ships if you do too.
This affects mainly WorldMap/DirectSail encounters.

I don't dare to guarantee that setting works as it should though. I didn't know anyone actually used that! :shock
 
But about the Indian Weapons Bug:
should I still set the price to 2 for these?
"arrows2", "rockets", "rocketbag"

And might I ask why the musket (accuracy from 80 to 60) and the armor (bulletstop reduced) were nerved?^^
 
But about the Indian Weapons Bug:
should I still set the price to 2 for these?
"arrows2", "rockets", "rocketbag"
I think those are quest-only items by @Jack Rackham. I'll leave it up to him if he thinks those should be changed too.

And might I ask why the musket (accuracy from 80 to 60) and the armor (bulletstop reduced) were nerved?^^
Paying attention, you are! Can't secretly slip any additional changes past you, eh? Good!

Those musket/armour changes are related to some discussions we were having the past week here:
Planned Feature - Correctly Assign Weapons for Character Type | Page 2 | PiratesAhoy!
You're welcome to join in some we can decide what would make the most sense. :doff
 
> Can't secretly slip any additional changes past you, eh?
Not on the files I'm "watching" :p

> You're welcome to join in...
Will do!
 
Not on the files I'm "watching" :p
Good! I prefer if people actually pay attention and check what happens.
Bad decisions and mistakes with the code are easily made. But they're far less likely if other people are around to do some double-checking. :onya
 
Back
Top