Jump to content

Renaming a Sector?


Shrooblord

Recommended Posts

Hiya,

 

Just founded my first couple of asteroid mines and stations! Whoop whoop!

 

However, the Sector name is "-72: -193" (guess where it is on the Galaxy Map). Is there a way to rename the Sector, like all AI-controlled Sectors have? Names like "Ephemeral Alpha", "Sanctuary of Hope" and "Final Graveyard" are super atmospheric and cool, and I'd like to have a cool name too, rather than being the odd one out who numbers his Sectors rather than naming them. :(

 

Or is there maybe a mod out there somewhere that does this? Did a quick surface scan search myself, but didn't find anything.

Link to comment
Share on other sites

Hm, too bad. That sounds very manual. If that's the only way, I'm guessing it's gonna be hard / unfeasible to try and include this functionality by modding it in. I'll keep looking around the code though, just in case.

 

Thank you for the suggestion. I'll check it out!

Link to comment
Share on other sites

Okay so the Sector data in the AppData folder for my Sector looks like this:

 

 

<?xml version="1.0" encoding="utf-8"?>
<view numCrafts="10" numWrecks="40" numAsteroids="1" numStations="4" influence="38.0680008" factionIndex="1" deathLocation="false">
<coordinates x="-77" y="-162"/>
<titles>
	<title str="Silver Mine"/>
	<title str="Gold Mine"/>
	<title str="Silicium Mine"/>
	<title str="Zinc Mine"/>
</titles>
<wormholes/>
<gates/>
<shipNumbers>
	<ships n="5" faction="1"/>
	<ships n="5" faction="2000150"/>
</shipNumbers>
</view>

 

which is pretty cool. Notice how the player's own faction is factionIndex 1, which is good to know. I was fearing it would be a "random" number like the 2000150 of the faction who has some traders over in my Sector. Also good to see that the Sector is actually considered controlled by me, as indicated by the factionIndex="1" at the top in the <view> tag.

 

What intrigues me are the entries <wormholes/> and <gates/>. Sure enough, for Sectors that have a wormhole or gate, this information is filled out:

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<view numCrafts="6" numWrecks="0" numAsteroids="821" numStations="7" influence="66.6189957" factionIndex="2000150" deathLocation="false">
<coordinates x="-82" y="-164"/>
<titles>
	<title str="${good} Factory ${size}">
		<arg key="good">Rubber</arg>
		<arg key="plural">Rubber</arg>
		<arg key="size">M</arg>
		<arg key="prefix">Rubber /* prefix */</arg>
	</title>
	<title str="${good} Factory ${size}">
		<arg key="good">Energy Inverter</arg>
		<arg key="plural">Energy Inverters</arg>
		<arg key="size">M</arg>
		<arg key="prefix">Energy Inverter /* prefix */</arg>
	</title>
	<title str="${good} Factory ${size}">
		<arg key="plural">Power Units</arg>
		<arg key="size">S</arg>
		<arg key="prefix">Power Unit /* prefix */</arg>
		<arg key="good">Power Unit</arg>
	</title>
	<title str="Noble Metal Mine ${size}">
		<arg key="plural">Silver</arg>
		<arg key="prefix">Silver /* prefix */</arg>
		<arg key="good">Silver</arg>
		<arg key="size">M</arg>
	</title>
	<title str="${good} Factory ${size}">
		<arg key="good">Display</arg>
		<arg key="plural">Displays</arg>
		<arg key="prefix">Display /* prefix */</arg>
		<arg key="size">S</arg>
	</title>
	<title str="Trading Post"/>
	<title str="Turret Factory"/>
</titles>
<wormholes/>
<gates>
	<coordinates x="-81" y="-161"/>
	<coordinates x="-84" y="-166"/>
</gates>
<shipNumbers>
	<ships n="6" faction="2000150"/>
</shipNumbers>
</view>

 

 

So I decided to add some entries for my own Sector:

<gates>
	<coordinates x="-79" y="-163"/>
	<coordinates x="-77" y="-161"/>
</gates>

I included my own coordinates in those Sectors' files. I decided to modify the factionIndex for one of these Sectors, too. They were neutral Sectors before (factionIndex=""), so I put my "1" in there.

 

I restarted the game, and here's what happened.

 

Nothing! The game could not be fooled. It reverted the XML files back to their state before my edits, and even changed them a little based on the fact that there were now Xsotan inside my Sector. So if these files don't actually store data in a way that is meaningful, or at least without changing some other data somewhere else, what are they for...??

 

----

 

That aside, I never found the name for the Sector stored anywhere. For each Sector, there's an x_y and an x_yv file, i.e. -77_-162 and -77_-162v for my Sector in question (no file extensions). The "v" files are readable XML, as displayed throughout this post. However, the "not-v" files seem to be encrypted or binary data. When opened up, they're all gobbledey-gook. Too bad.

 

My search continues!

Link to comment
Share on other sites

Very interesting, I have looked through both the normal directory and the appdata folder and that seems to be the only area dedicated to the world saves...

Thanks for checking. I thought as much, but the confirmation definitely helps narrow down the search. So we know we must be able to change the game information for particular galaxies by editing the AppData folder, since that's the only place where this information gets saved. Good.

 

Okay so, I've tried hacking into it using Cheat Engine while the game was running, and I've tried rummaging around the "non-v" file with a hex editor.

 

The hex editor meddling was ineffective because I couldn't find a single pointer that made any sense. All the byte data is garbled nonsense, so I'm guessing it's compressed or encrypted in some way that makes it harder to read with a hex editor. I'm not nearly experienced enough in hacking game files to know what to do with those kinds of files, so my search on that front ended there, for now.

 

Cheat Engine was more interesting. When you search for a string of a Sector name - one of my neighbours' Sectors is called "Unforgiving Bulwark V", so let's roll with that -, you end up with a small amount of results, around 8 or less, more depending on whether you're currently in the Sector or in a Sector whose Gate leads towards it, less if you're in an unconnected part of the galaxy. What's interesting is that you find the memory addresses that point to these locations when you inspect the client as well as the server process. This makes sense, I guess, but it's something to keep in mind: we may need to direct our attention to the server process as that's generally in gaming terms what governs what goes; it's the boss, and clients are the interface between the boss of the game and the player. I digress.

 

So editing Unforgiving Bulwark V into something else, like "Unforgiving Bulwark X" or "My Friends" had an interesting set of results:

[*]While in the Sector, the displayed name doesn't always change when you change the value, but sometimes it does. Yay progress!

 

 

 

[*]While the Galaxy Map is open, the name doesn't change. If you reopen the map, the change has occurred.

 

 

 

[*]Whatever you do, the name displayed on a Gate leading towards the Sector doesn't ever change. Perhaps this is information that is read from the "non-v" file when you load the Galaxy, and is never accessed again. Then again, editing the value in memory would presumably change this value too, but my test results are inconclusive to this being the case.

 

 

 

[*]When you jump from Sector to Sector, those eight values get narrowed down to two or three, as the other addresses all change.

 

 

 

[*]When you change the value of these remaining three addresses, the Sector name gets updated. However, jumping to and from the Sector may change it back. More on that later.

 

 

 

[*]Sometimes when you change the value of the memory address pertaining to the Sector name, then jump to that Sector, the game crashes. I'm guessing there's a mismatch in what the game expects and finds, or something being looked up in an array with an index that doesn't exist.

Or anything else at all is going wrong. Who knows. :P

 

 

 

[*]Every time you scan for the value of the address using Cheat Engine, the value is listed as the value you scanned for, regardless of edits made; this is very weird to me, but maybe I'm just not getting something when it comes to how memory searching works.

 

 

 

[*]If you change the name into something that has more characters than the original, the change is put forward.

 

 

 

[*]If you use less characters than the original, the change is put forward, but the remaining characters "beyond" the amount of characters you provided are also put forward, so "Unforgiving Bulwark V" becomes "My Friendsg Bulwark V" even though I entered "My Friends". No amount of adding null byte characters "0x00" to the actual memory addresses seems to change this; in fact, as soon as you try to introduce those null bytes to shorten the string length, it gets changed back.

 

 

 

[*]Sectors currently controlled by a faction, which therefore already have a name, can have their name changed. Uncontrolled Sectors with coordinates for names, or Sectors controlled by you, the player, never accept the changes you make. The name is changed while in-game, but when you save and reload, the name is changed back to the original. This is unfortunate, because it's exactly this which I want to achieve. :P

 

 

 

[*]Your best bet for trying to get the name to "stick" when you reload the game is to change all the memory addresses, quit the game so it saves, and restart Avorion. However, some scenarios still change the name back to the original, while others do not. I'm not sure yet what exactly causes this to happen, but my guess is that memory adresses changed while the game is running doesn't actually reflect back into the stored "non-v" file in the AppData folder; in fact, the name I'm assuming is stored inside there somewhere may very well be write-once-and-only-ever-read, if you know what I mean, so short of editing the file directly somehow (getting around the compression/encryption therefore) may very well mean that we can't edit the Sector name at all after it's been generated. Sadface.

 

While not completely conclusive, I feel like I've learned a lot already about how this system works. Now if only I could crack open that compressed/encrypted "non-v" file, I think I'd get a lot more insight into the matter...

 

I'm going to pause for now and actually play the game again for a bit. ;)

Link to comment
Share on other sites

More success: I found the sectorspecifics.lua and sectornamegenerator.lua scripts, which very unambiguously set the Sector name thusly:

 

--SECTORSPECIFICS.LUA
SectorNameGenerator = require ("sectornamegenerator")
require ("galaxy")

-- determine the number of the sector in the grid
        local lx, ly, ux, uy = SectorNameGenerator.gridDimensions(x, y)
        local c = 1

        for oy = ly, uy - 1 do
            for ox = lx, ux - 1 do
                if ox == x and oy == y then goto continue end

                local regular = self:determineContent(ox, oy, serverSeed)
                if regular then c = c + 1 end
            end
        end

        ::continue::

        self.name = SectorNameGenerator.generateSectorName(x, y, c, serverSeed)
--END SECTORSPECIFICS.LUA

 

I'm going to try and figure out if invoking a function that sets the self.name variable in a similar way as set by sectorspecifics.lua permanently replaces the Sector's name in a meaningful way. If that works, I'm going to try and get a text box pop up like when the player names their ship, and see if I can set it to any custom name the player desires.

 

We're one step closer to greater understanding!

Link to comment
Share on other sites

  • 2 weeks later...

Well, I dived into this a little more, and I'm getting weird errors I'm running into a wall for how to solve. The most annoying one, so far, is that I can't seem to query Sector() like I see all other scripts in the original Avorion code and other mods just "simply do". Whenever I try, I get told that Sector() is a nil value, and thus the script crashes / doesn't execute (as told to me by the Console).

 

This is rather bugging me, and right now I can't think clearly enough to understand why it's not working.

 

Let's just say that so far, what seems like a trivial task proves to proffer more challenges than expected, as always with programming.

 

EDIT:

Okay I just found a way to print the Sector name. Turns out the game doesn't like calls to Sector() unless the script executing those calls is in one of a select subset of folders. So far, I've found that putting the script in scripts/sector and adding it manually using the EntityDebugger does the trick.

 

However, sector.name seems to be read-only. I can get it and print it to console, but trying to change it by doing sector.name = "New Name" spits out an error to Console claiming that the property could not be found or is not writable. Since it could be found just one line earlier as it printed to Console, I must conclude it's not writable.

 

Curious! Given that the name is freely altered at time of Sector generation, I wonder at what point in the game's programming does it "lock down" that name and make it read-only. I have not found this code yet.

 

Stay tuned.

 

EDIT II:

Ah, yes. Documentation:

property string name [read-only]

Damnit. Let me see how to get around this.

 

EDIT III:

Okay. It would seem the Sector name is a property inherited through the C++ code of the game, and is read-only. That is to say, it simply isn't writable at this time. :(

I'll make a suggestion on the Suggestions forum to request access to the Sector name.

Link to comment
Share on other sites

Yeah, I looked into this for about two days and came to the same conclusion.

It's just not available at the moment.

 

It seems the sector name is randomly generated and then stored in some database file.

But after generation, it doesn't seem to be possible to change it at the moment.

Link to comment
Share on other sites

  • 3 weeks later...

Heh. Heh. Heh.

 

I just tried another shot at renaming Sectors.

 

local SectorSpecifics = require("sectorspecifics")

function InactiveGate.renameSector()
    if onServer() then
        local x,y = Sector():getCoordinates()
        
        local specs = SectorSpecifics(x, y, getGameSeed())
        specs.name = "Hey There"
    end
end

 

Guess what? The game crashes. Turns out there is a way to trigger the Sector renaming behaviour, but the C++ side of things is ill-equipped with handling the situation (probably because it's supposed to be read-only, yet here we are modifying it), just can't even, and bails.

 

Too bad!

 

We return to the waiting game of hoping that the devs make the Sector name a writable property...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...