Skip to content

Commit

Permalink
Merge pull request #27 from JennyKmu/dev_v037
Browse files Browse the repository at this point in the history
v0.3.7 release
  • Loading branch information
JennyKmu committed Nov 9, 2021
2 parents 2266496 + 302d1cb commit 55ca9ac
Show file tree
Hide file tree
Showing 8 changed files with 1,517 additions and 369 deletions.
68 changes: 47 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RROSE - v0.3.6
# RROSE - v0.3.7

This program is intended to be used as an external tool to Railroads Online server hosts. It will read save files, allow to modify entries within it, and then save the file (creating a backup file in the process).

Expand All @@ -8,7 +8,7 @@ There are two ways to use the program. You can either:
* Disadvantages: you need to properly setup your python environment the first time, though once it's done it will be straightforward to add the newly required modules with each update.
* Use the standalone .exe files.
* Advantages: only one file to download and execute, theoretically no need to install python or anything else.
* Disadvantages: the executable is heavier, you'll have to fully download it with each update, it can only run on Windows, and might not run at all depending on your configuration.
* Disadvantages: the executable is heavier, you'll have to fully download it with each update, it can only run on Windows, and might not run at all depending on your configuration. **Windows defender will flag the .exe as containing a virus, while it is not the case**. You can reassure yourself by checking the SHA256 hash of the file you downloaded (see below).

Below is the detailed guide for using the .pyz files.

Expand All @@ -18,68 +18,94 @@ Using the .exe is straightforward: download the .exe file, place it in the same

With each release will be included the SHA-256 hash of the .pyz and .exe files. This made to check that the files haven't been tempered with since they were prepared for release (meaning that no one modified them). To check that the hash is correct, open a command prompt (powershell) at the location of the downloaded file, and type: ``Get-FileHash <filename> -Algorithm SHA256 | Format-List``. Compare the result to the hash given with the release notice.

## Requirements
## Requirements (for .pyz file)

* Having a working Python 3 install. Development was made using Python 3.8, so the program will warn you if you try using an older version, but allow you to continue if it's a Python 3 version.
* Having a working Python 3 install. Development was made using Python 3.10, so the program will warn you if you try using an older version, but allow you to continue if it's a Python 3 version above Python 3.9.
* Having necessary python modules installed:
* numpy (see https://pypi.org/project/numpy/ )

Setting up pip so that you can easily install python modules is recommended. More requirements will be added in the future.

## Installation and Use
## Installation and Use -- Python (.pyz release)

1. Save your game.
2. Download the last .pyz file from the **release** list (https://github.com/JennyKmu/RRO_savefile_editor/releases) and place it inside your save folder (should be located somewhere around ``C:\Users\Username\AppData\Local\arr\Saved\SaveGames`` ). **No need to decompress the file**, if your python install was properly made, windows will correctly detect it as a python program.
2. Download the latest .pyz file from the **release** list (https://github.com/JennyKmu/RRO_savefile_editor/releases) and place it inside your save folder (should be located somewhere around ``C:\Users\Username\AppData\Local\arr\Saved\SaveGames`` ). **No need to decompress the file**, if your python install was properly made, windows will correctly detect it as a python program.
3. Even though the program will create backups of your saves, **it is still recommended to create your own backups.**
4. Double-click on the .pyz file, and follow instructions. At any point, you can exit the program by pressing ``Ctrl+D`` (or less cleanly by pressing ``Ctrl+C``)
5. Likewise, you can always go back to previous menu by pressing ``Escape`` (escaping from the savefile selection menu will exit the program).
5. Exit the current session in-game or start the game, and load the file you edited.
6. Exit the current session in-game or start the game, and load the file you edited.

## Installation and Use -- Standalone Executable (.exe release)

1. Save your game.
2. Download the latest .exe file from the **release** list (https://github.com/JennyKmu/RRO_savefile_editor/releases) and place it inside your save folder (should be located somewhere around ``C:\Users\Username\AppData\Local\arr\Saved\SaveGames`` ). **Windows defender will flag the file as containing a virus, which is not the case.**
3. Even though the program will create backups of your saves, **it is still recommended to create your own backups.**
4. Double-click on the .exe file, and follow instructions. At any point, you can exit the program by pressing ``Ctrl+D`` (or less cleanly by pressing ``Ctrl+C``)
5. Likewise, you can always go back to previous menu by pressing ``Escape`` (escaping from the savefile selection menu will exit the program).
6. Exit the current session in-game or start the game, and load the file you edited.

## Functionalities

Currently, functionnalities are limited to:
* Editing xp value for each player;
* Editing money value for each player;
* Editing rolling stock names and numbers;
* Editing is limited to what can be displayed on each rolling stock. Override by starting with \i when entering a new value.
* Rolling stock clean-up (**EXPERIMENTAL**):
* Attempts to detect rolling stock which fell through the map, and moves them high up in the air, for you to recover them and rerail them. Watch out for your head!
* Editing is limited to what can be displayed on each rolling stock. Override by starting with `\i` when entering a new value.
* Editing cargo on wagons:
* Changing cargo type (within allowed types and empty)
* Upon switching to 'Empty', the wagon is emptied. If switching to any cargo, the wagon is filled.
* Changing cargo amount
* Editing Engine and Tender contents:
* Refill firewood, water, but not sand as it is not yet saved by the game.
* Editing Utility contents:
* Can refill water towers
* Cannot refill sand towers as it is not yet saved by the game.
* Can refill firewood depots
* Rolling stock respawn :
* Allows to respawn rolling stock at one of the six spawn points. The rolling stock should be re-railed when respawning at one of the spawn points.
* If all the points are occupied, an option is available to teleport rolling stock close to the spawn points (behind the deck at the end of the tracks).
* Detects most cars that fell through the ground and indicates them in the menu.
* Reset trees (**EXPERIMENTAL**) back to the state they are in when starting a new game.

## In the work

* Editing rolling stock contents
* Plotting a map of the network
* Build new tracks
* Better tree reset feature (avoid existing tracks)
* Exporting SVG files of the network
* Editing industries contents
* Editing water, sand and firewood places contents
* Teleportation of rolling stock and players, as well as rerailing
* Teleportation of players
* Better teleportation of rolling stock, as well as rerailing
* Deletion of rolling stock, tracks, or players
* A "No cheat" mode, which will allow to take loans, sell unused rolling stock (at a lower price), order refills for water, sand or firewood...
* Improvements of the UI
* GUI
* GUI (or JUI as Leif likes to call it)

## Q&A

* **The program starts, but doesn't find any savefile**
* Check that the program is placed in the right folder, next to your saves
* If it is, then it's most likely an issue with your python installation. Reinstall it from the official https://www.python.org/downloads/. Also check you're using a version 3.x. **Installation from Windows Store will not work !**
* If it is, and you're using the .pyz release, then it's most likely an issue with your python installation. Reinstall it from the official https://www.python.org/downloads/. Also check you're using a version 3.10+. **Installation from Windows Store will not work properly!**
* **The program starts, but tells me a module is not found**
* Install the python module that was not found using pip. Check below for detailed instruction.
* The UI is not yet functionnal with Unix sytems, and hasn't been tested with Mac (probably not working either).
* If you can't find a solution to your issue, the preferred way is to open an new issue on GitHub, and if necessary join your savefile there: https://github.com/JennyKmu/RRO_savefile_editor/issues
* **Windows tell me there's a virus in the released .exe file**
* There's no virus.
* You can check the SHA256 hash to check that the file you downloaded isn't corrupted.
* Making it so Windows doesn't see a virus in the file would be too much of a hassle at this stage of development.
* If you really don't want to use the .exe file because of that, you can always use the .pyz version which won't trigger Windows Defender.
* The UI is not yet functional with Unix systems, and hasn't been tested with Mac (probably not working either).
* If you can't find a solution to your issue, the preferred way is to open an new issue on GitHub (if necessary joining your savefile, changing the extension to .txt so that GitHub allows you to upload it) there: https://github.com/JennyKmu/RRO_savefile_editor/issues

## Setting up the environment
## Setting up the environment -- Python (.pyz release)

* First go to the official https://www.python.org/downloads/, download Python 3 (latest release recommended), and install it. When asked so, **add pip to Path**.
* Open a command prompt (cmd or powershell) as administrator, and type in:
* Open a command prompt (cmd or powershell) as administrator, and type in either:
* ``pip install numpy``
* ``python -m pip install numpy``

If you already had installed Python, but the pip command doesn't work, then you'll need to add pip to Path yourself (you probably didn't check the option originally). To do so:
If you already had installed Python, but the pip command doesn't work, then you'll need to add pip to Path yourself (you probably didn't check the option to do so when installing Python originally). To do so:
* In the Windows search bar, look for "Environment Variables", and open the tool that shows up.
* In that tool, click "Environment Variables"
* Select the "Path" variable, and click "Modify"
* **Do not delete anything there**. Add a new line, in which you will put the Path/To/Python/Install/Scripts (Usually C:\\Users\\Username\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts)
* Apply your changes and exit the tool. Now pip should work well.
* Apply your changes and exit the tool. Now pip should work well, go back to first step.
19 changes: 10 additions & 9 deletions RRO_savefile_editor/GVAS/GVAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _readBoolPropertyArray(self, fstream, prop, plen):
nbool = readInt32(fstream)
buffer = fstream.read(nbool)
# print(repr(buffer))
data = np.frombuffer(buffer, dtype=np.bool).copy()
data = np.frombuffer(buffer, dtype=bool).copy()
prop._data = data

def _readIntPropertyArray(self, fstream, prop, plen):
Expand Down Expand Up @@ -308,13 +308,13 @@ def _writeStrPropertyArray(self, fstream, prop):
writeInt32(fstream, len(prop.data))
sz = 0
for w in prop.data:
# print(repr(w))
if w is None or w == '':
sz += 4
elif isUTF8(w) :
sz += 4 + len(w) + 1
else:
sz += 4 + 2*len(w) + 2
sz += 4 + len(w.encode('utf-16')) # is two bytes too long
# so no need to add 2 bytes for the trailing 0x0000
writeUEString(fstream, w)
sz += 4
# print(prop.name, sz)
Expand Down Expand Up @@ -586,12 +586,12 @@ def writeUEString(fstream, s):
if s == '':
writeInt32(fstream, 1)
return
buffer = s.encode('utf8')
if len(buffer) > len(s):
if not isUTF8(s):
buffer = s.encode('utf16')[2:]
writeInt32(fstream, -len(s)-1)
writeInt32(fstream, -int(len(buffer)/2)-1)
writeStr(fstream, buffer, end=b'\x00\x00')
else:
buffer = s.encode('utf8')
writeInt32(fstream, len(buffer)+1)
writeStr(fstream, buffer)

Expand All @@ -611,8 +611,9 @@ def isUTF16(s):
import glob
print("{:-^72s}".format(" Running unit tests for file `GVAS.py` "))
# test_files = ["../../slot{}.sav".format(i) for i in range(1,11)]
test_files = glob.glob('../../slot*.sav')
# test_files = ["../../slot7.sav"]
# test_files = glob.glob('../../slot*.sav')
# test_files = glob.glob('../../sav_test_cases/*.sav')
test_files = ["../../slot3.sav"]
total_passed_count = 0
total_failed_count = 0
import os.path
Expand Down Expand Up @@ -704,7 +705,7 @@ def isUTF16(s):
print("{:-^72s}".format('-'))


DEBUG = True
DEBUG = False
if DEBUG:
# For debugging, put whatever you want to do there
print("> Advanced debug:")
Expand Down
45 changes: 45 additions & 0 deletions RRO_savefile_editor/UI/industryPlacables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
industryNames = {
2: "Logging Camp",
3: "Sawmill",
4: "Iron Mine",
5: "Smelter",
6: "Coal Mine",
7: "Ironworks",
8: "Oilfield",
9: "Refinery",
}


industryInputs = {
3: {"log": 100},
4: {"beam": 20, "lumber": 24},
5: {"cordwood": 100, "ironore": 1000},
6: {"beam": 20, "rail": 100},
7: {"coal": 1000, "rawiron": 100},
8: {"beam": 20, "steelpipe": 100, "crate_tools": 100},
9: {"lumber": 20, "steelpipe": 100, "crudeoil": 1000},
}


industryOutputs = {
2: {"log": 100, "cordwood": 100},
3: {"beam": 100, "lumber": 100},
4: {"ironore": 290},
5: {"rail": 100, "rawiron": 100},
6: {"coal": 750},
7: {"steelpipe": 100, "crate_tools": 100},
8: {"crudeoil": 1000},
9: {"oilbarrel": 100, "oilbarrel2": 100},
}


firewoodDepot = {
"type": 10,
"input": [32],
"output": [100, 100, 100, 100]
}

waterTower = {
"type": 0,
"output": 360
}

0 comments on commit 55ca9ac

Please sign in to comment.