mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-08-14 03:15:35 +02:00
fix steam id for generated codex ini
now using steam id3 (correct) instead of steam id64 (wrong)
This commit is contained in:
parent
1d68c3d58b
commit
398ae35d99
4 changed files with 182 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
from steam_id_converter.SteamID import (
|
||||||
|
SteamID
|
||||||
|
)
|
||||||
|
|
||||||
__codex_ini = '''
|
__codex_ini = '''
|
||||||
### ÜÛÛÛÛÛ Ü
|
### ÜÛÛÛÛÛ Ü
|
||||||
|
@ -162,10 +165,12 @@ def generate_cdx_ini(
|
||||||
achs_list.append(f'{ach["name"]} Achieved={icon}') # unlocked
|
achs_list.append(f'{ach["name"]} Achieved={icon}') # unlocked
|
||||||
achs_list.append(f'{ach["name"]} Unachieved={icon_gray}') # locked
|
achs_list.append(f'{ach["name"]} Unachieved={icon_gray}') # locked
|
||||||
|
|
||||||
|
steam_id = SteamID(accountid)
|
||||||
|
|
||||||
formatted_ini = __codex_ini.format(
|
formatted_ini = __codex_ini.format(
|
||||||
cdx_id = appid,
|
cdx_id = appid,
|
||||||
cdx_username = username,
|
cdx_username = username,
|
||||||
cdx_accountid = accountid,
|
cdx_accountid = steam_id.get_steam32_id(),
|
||||||
cdx_language = language,
|
cdx_language = language,
|
||||||
cdx_dlc_list = "\n".join(dlc_list),
|
cdx_dlc_list = "\n".join(dlc_list),
|
||||||
cdx_ach_list = "\n".join(achs_list)
|
cdx_ach_list = "\n".join(achs_list)
|
||||||
|
|
32
tools/generate_emu_config/steam_id_converter/README.md
Normal file
32
tools/generate_emu_config/steam_id_converter/README.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# SteamID-Converter-python
|
||||||
|
A python class that helps you convert the different user steam id types from one to another.
|
||||||
|
|
||||||
|
This script **doesn't** need an internet connection. It will **calculate** the steam id's.
|
||||||
|
|
||||||
|
Important: This class only works with steam ids of users.
|
||||||
|
Other Types of [steam accounts](https://developer.valvesoftware.com/wiki/SteamID#Types_of_Steam_Accounts)
|
||||||
|
are not supported!
|
||||||
|
|
||||||
|
But this should work for the most usecases.
|
||||||
|
|
||||||
|
Base information about the different kinds of Steam IDs:
|
||||||
|
https://developer.valvesoftware.com/wiki/SteamID
|
||||||
|
|
||||||
|
This script supports the following steam IDs:
|
||||||
|
|
||||||
|
| ID type | example |
|
||||||
|
|----------------|----------------------------------|
|
||||||
|
| SteamID | STEAM_0:1:40370747 |
|
||||||
|
| Steam ID3 | U:1:80741495 or [U:1:80741495] |
|
||||||
|
| Steam32 ID | 80741495 |
|
||||||
|
| Steam64 ID | 76561198041007223 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## example code
|
||||||
|
```python
|
||||||
|
from SteamID import SteamID
|
||||||
|
|
||||||
|
steam_id = SteamID("76561198041007223")
|
||||||
|
print(steam_id.get_steam_id()) # returns STEAM_0:1:40370747
|
||||||
|
```
|
28
tools/generate_emu_config/steam_id_converter/SOURCE.txt
Normal file
28
tools/generate_emu_config/steam_id_converter/SOURCE.txt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#### INFO
|
||||||
|
|
||||||
|
https://github.com/callFEELD/SteamID-Converter-python
|
||||||
|
|
||||||
|
VERSION: https://github.com/callFEELD/SteamID-Converter-python/tree/833b5e127c48dd22f2fca53ad344a978a336c0d6
|
||||||
|
|
||||||
|
#### LICENSE
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
Copyright (c) 2019 callFEELD
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
116
tools/generate_emu_config/steam_id_converter/SteamID.py
Normal file
116
tools/generate_emu_config/steam_id_converter/SteamID.py
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
"""
|
||||||
|
User SteamID
|
||||||
|
This Class helps you convert the different user steam id types from one to another
|
||||||
|
Important this class only works with steam ids of users.
|
||||||
|
Other Types of steam accounts (https://developer.valvesoftware.com/wiki/SteamID#Types_of_Steam_Accounts)
|
||||||
|
are not supported!
|
||||||
|
|
||||||
|
But this should work for the most usecases.
|
||||||
|
|
||||||
|
Base information about the different kinds of Steam IDs:
|
||||||
|
https://developer.valvesoftware.com/wiki/SteamID
|
||||||
|
|
||||||
|
This scripts support those kind of steam IDs:
|
||||||
|
|
||||||
|
| ID type | example |
|
||||||
|
|----------------|----------------------------------|
|
||||||
|
| SteamID | STEAM_0:1:40370747 |
|
||||||
|
| Steam ID3 | U:1:80741495 or [U:1:80741495] |
|
||||||
|
| Steam32 ID | 80741495 |
|
||||||
|
| Steam64 ID | 76561198041007223 |
|
||||||
|
"""
|
||||||
|
|
||||||
|
class InvalidSteamID(Exception):
|
||||||
|
def __init__(self,*args,**kwargs):
|
||||||
|
Exception.__init__(self, "The given steam id is not valid.")
|
||||||
|
|
||||||
|
|
||||||
|
class SteamID:
|
||||||
|
x:int = None
|
||||||
|
y:int = None
|
||||||
|
z:int = None
|
||||||
|
|
||||||
|
def __init__(self, any_steamid:str):
|
||||||
|
"""
|
||||||
|
Insert any kind of steam id as a string in the init method
|
||||||
|
:param any_steamid: One of the differnt kinds of steamids as string
|
||||||
|
"""
|
||||||
|
self.convert(any_steamid)
|
||||||
|
|
||||||
|
def get_steam64_id(self):
|
||||||
|
return int(self.get_steam32_id() + 0x0110000100000000)
|
||||||
|
|
||||||
|
def get_steam32_id(self):
|
||||||
|
return int(2 * int(self.z) + int(self.y))
|
||||||
|
|
||||||
|
def get_steam_id3(self):
|
||||||
|
return f"U:{self.y}:{self.get_steam32_id()}"
|
||||||
|
|
||||||
|
def get_steam_id(self):
|
||||||
|
return f"STEAM_{self.x}:{self.y}:{self.z}"
|
||||||
|
|
||||||
|
def convert(self, any_steamid:str):
|
||||||
|
"""
|
||||||
|
This method will convert the class variables to the different kinds
|
||||||
|
of steam ids, based on the paramerter.
|
||||||
|
:param any_steamid: One of the differnt kinds of steamids as string
|
||||||
|
"""
|
||||||
|
# preprocessing, lower the text and remove spaces
|
||||||
|
any_steamid = any_steamid.lower()
|
||||||
|
any_steamid = any_steamid.replace(" ", "")
|
||||||
|
|
||||||
|
# check the kind of steam id from the input parameter
|
||||||
|
try:
|
||||||
|
# check if its a steam64 id
|
||||||
|
steamid = int(any_steamid)
|
||||||
|
if len(bin(steamid)) >= 32:
|
||||||
|
steam32_id = steamid - 0x0110000100000000
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0 if steam32_id % 2 == 0 else 1
|
||||||
|
self.z = int( (steam32_id - self.y) / 2 )
|
||||||
|
|
||||||
|
if len(bin(steamid)) < 32:
|
||||||
|
steam32_id = steamid
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0 if steam32_id % 2 == 0 else 1
|
||||||
|
self.z = int( (steam32_id - self.y) / 2 )
|
||||||
|
|
||||||
|
except ValueError:
|
||||||
|
# there is a character inside the id
|
||||||
|
# now it can only be two types of steam ids
|
||||||
|
# either steamid3 or steamid
|
||||||
|
if any_steamid.startswith("steam_"):
|
||||||
|
# this is a steam id
|
||||||
|
any_steamid.replace("steam_", "")
|
||||||
|
steamid_parts = any_steamid.split(":")
|
||||||
|
|
||||||
|
self.x = steamid_parts[0]
|
||||||
|
self.y = steamid_parts[1]
|
||||||
|
self.z = steamid_parts[2]
|
||||||
|
|
||||||
|
self.steam32_id = 2 * self.z + self.y
|
||||||
|
|
||||||
|
if any_steamid.startswith("["):
|
||||||
|
# this is a steam id3
|
||||||
|
any_steamid.replace("[", "")
|
||||||
|
any_steamid.replace("]", "")
|
||||||
|
any_steamid.replace("u:", "")
|
||||||
|
steamid_parts = any_steamid.split(":")
|
||||||
|
self.x = 0
|
||||||
|
self.y = steamid_parts[0]
|
||||||
|
self.z = int( (steamid_parts[1] - self.y) / 2 )
|
||||||
|
|
||||||
|
if any_steamid.startswith("u"):
|
||||||
|
any_steamid.replace("u:", "")
|
||||||
|
steamid_parts = any_steamid.split(":")
|
||||||
|
self.x = 0
|
||||||
|
self.y = steamid_parts[0]
|
||||||
|
self.z = int( (steamid_parts[1] - self.y) / 2 )
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
raise InvalidSteamID
|
||||||
|
|
||||||
|
# check if the information is there
|
||||||
|
if self.x is None or self.y is None or self.z is None:
|
||||||
|
# if not throw an error
|
||||||
|
raise InvalidSteamID
|
Loading…
Add table
Reference in a new issue