Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Fixed update stability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-90 committed Nov 19, 2023
1 parent 1c5013b commit ba70029
Show file tree
Hide file tree
Showing 26 changed files with 167 additions and 110 deletions.
23 changes: 19 additions & 4 deletions packages/dll/src/UE425/ftext.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,20 @@ struct FTextData2
uint32_t Length;
};


struct FTextData3
{
unsigned char UnknownData00[0x10];
wchar_t* Name;
uint32_t Length;
};

union FTextData
{
FTextData1 type1;
FTextData2 type2;
FTextData3 type3;
FString type4;
};

struct FText
Expand All @@ -70,17 +80,22 @@ struct FText
if (!Data || IsBadReadPtr(Data, sizeof(Data))) return nullptr;

// Atemmpt 1 to read FText
wchar_t* str_1 = Data->type3.Name;
if (!IsBadReadPtr(str_1, sizeof(str_1)))
return str_1;

// Atemmpt 2 to read FText
wchar_t** str_ptr = Data->type1.Name;
if (!IsBadReadPtr(str_ptr, sizeof(str_ptr))) {
wchar_t* str = *str_ptr;
if (!IsBadReadPtr(str, sizeof(str)))
return str;
}

// Attempt 2 to read FText
wchar_t* str = Data->type2.Name;
if (!IsBadReadPtr(str, sizeof(str)))
return str;
// Attempt 3 to read FText
wchar_t* str_3 = Data->type2.Name;
if (!IsBadReadPtr(str_3, sizeof(str_3)))
return str_3;

return nullptr;
}
Expand Down
17 changes: 12 additions & 5 deletions packages/dll/src/UE425/uobjectarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ FUObjectItem* TUObjectArray::GetObjectPtr(int32_t Index) {
}

FUObjectItem* FUObjectArray::FindObject(const std::string& name) {
std::unordered_map<std::string, FUObjectItem*>::const_iterator cached = Cache.find(name);
std::string nameLowerCase = name;
std::transform(nameLowerCase.begin(), nameLowerCase.end(), nameLowerCase.begin(), ::tolower);

std::unordered_map<std::string, FUObjectItem*>::const_iterator cached = Cache.find(nameLowerCase);

if (cached != Cache.end()) {
FUObjectItem* item = cached->second;

if (item && !IsBadReadPtr(item, sizeof(FUObjectItem*))
&& item->Object && !IsBadReadPtr(item->Object, sizeof(UObject*))
&& item->Object->GetFullName() == name)
return item;
&& item->Object && !IsBadReadPtr(item->Object, sizeof(UObject*))) {
std::string objectName = item->Object->GetFullName();
std::transform(objectName.begin(), objectName.end(), objectName.begin(), ::tolower);
if(objectName == nameLowerCase)
return item;
}

Cache.erase(cached);
}
Expand All @@ -35,11 +41,12 @@ FUObjectItem* FUObjectArray::FindObject(const std::string& name) {

if (item && item->Object) {
std::string foundName = item->Object->GetFullName();
std::transform(foundName.begin(), foundName.end(), foundName.begin(), ::tolower);

if (Cache.find(foundName) == Cache.end())
Cache.insert({ foundName, item });

if (foundName == name)
if (foundName == nameLowerCase)
return item;
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/dll/src/UE425/uobjectarray.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <string>
#include <algorithm>
#include "base.h"
#include "uobject.h"

Expand Down
15 changes: 12 additions & 3 deletions packages/dll/src/query/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,18 @@ std::vector<int> QueryExecutor::getArrayIndices(int arraySize) {

bool QueryExecutor::isValidName(UObject* obj, std::string& name) {
WUObject wrapped = obj;
std::string nameLowerCase = name;
std::transform(nameLowerCase.begin(), nameLowerCase.end(), nameLowerCase.begin(), ::tolower);

if (wrapped.GetFullName() == name)
std::string wrappedName = wrapped.GetFullName();
std::transform(wrappedName.begin(), wrappedName.end(), wrappedName.begin(), ::tolower);
if (wrappedName == nameLowerCase)
return true;

WUClass wrappedClass = wrapped.GetClass();
if (wrappedClass.GetFullName() == name)
std::string wrappedClassName = wrappedClass.GetFullName();
std::transform(wrappedClassName.begin(), wrappedClassName.end(), wrappedClassName.begin(), ::tolower);
if (wrappedClassName == nameLowerCase)
return true;

while (wrappedClass) {
Expand All @@ -634,7 +640,10 @@ bool QueryExecutor::isValidName(UObject* obj, std::string& name) {
if (!super)
return false;

if(super.GetFullName() == name)
std::string superName = super.GetFullName();
std::transform(superName.begin(), superName.end(), superName.begin(), ::tolower);

if(superName == nameLowerCase)
return true;
if (!super.IsA<WUClass>())
return false;
Expand Down
1 change: 1 addition & 0 deletions packages/dll/src/query/query.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <stack>
#include <algorithm>
#include "../injector.h"
#include "../net/buffer.h"
#include "../UE425/uobject.h"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@rrox/electron",
"productName": "RailroadsOnline Extended",
"private": true,
"version": "2.2.1",
"version": "2.2.2",
"description": "Railroads Online Extended is a mod for the game Railroads Online",
"author": "_tom()",
"main": ".webpack/main",
Expand Down
1 change: 0 additions & 1 deletion packages/electron/src/main/query/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export class StructInstance<T extends object> implements StructInfo<T> {

const response = await pipe.waitForResponse( request, GetStructTypeResponse );

console.log( response.structType );
if( response.structType !== StructResponseType.Struct )
throw new StructInstanceError( 'Unexpected Struct response' );

Expand Down
6 changes: 3 additions & 3 deletions packages/electron/src/main/struct/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export class StructStore {
private storage: { [ name: string ]: Struct | Function | Enum } = {};

insert( struct: Struct | Function | Enum ) {
this.storage[ struct.fullName ] = struct;
this.storage[ struct.fullName.toLowerCase() ] = struct;
}

get( name: string ) {
return this.storage[ name ];
return this.storage[ name.toLowerCase() ];
}

has( name: string ): boolean {
return this.storage[ name ] != null;
return this.storage[ name.toLowerCase() ] != null;
}

clear() {
Expand Down
4 changes: 4 additions & 0 deletions plugins/map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ It is possible to enable the minimap under the minimap settings. **The minimap w

## Changelog

### v1.1.18 19-11-2023
- ``Fixed`` Issues where unknown rolling stock could crash the RROx map.
- ``Fixed`` Issues where some industries might not have showed up correctly.

### v1.1.17 14-11-2023
- ``Fixed`` Issues after new game update

Expand Down
2 changes: 1 addition & 1 deletion plugins/map/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rrox-plugins/map",
"version": "1.1.17",
"version": "1.1.19",
"description": "Map Plugin",
"author": "_tom()",
"contributors": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoupledFrameItem } from '@rrox-plugins/world/shared';
import { CoupledFrameItem, FrameCarType } from '@rrox-plugins/world/shared';
import React from 'react';
import { FrameDefinitions } from '../../definitions';

Expand All @@ -13,7 +13,7 @@ export function CouplingsBar( {
} ) {
return <div style={{ display: 'flex', overflowX: 'auto', maxWidth: '100%', minHeight: 50 }} className="couplingBar">
{coupledFrames.map( ( { frame, flipped, isCoupled, index }, i ) => {
const definition = FrameDefinitions[ frame.type ];
const definition = FrameDefinitions[ frame.type ] ?? FrameDefinitions[ FrameCarType.UNKNOWN ];

return <img
className='dark-mode-invert'
Expand Down
26 changes: 13 additions & 13 deletions plugins/map/src/renderer/map/components/frameControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react';
import { Slider, Popover, Switch } from "antd";
import { QuestionCircleOutlined } from "@ant-design/icons";
import { FrameDefinitions } from '../../definitions';
import { FrameCarControl, IFrameCar, getCoupledFrames, SetControlsSyncCommunicator, isEngine as checkIsEngine, SetControlsCommunicator } from '@rrox-plugins/world/shared';
import { FrameCarControl, IFrameCar, getCoupledFrames, SetControlsSyncCommunicator, isEngine as checkIsEngine, SetControlsCommunicator, FrameCarType } from '@rrox-plugins/world/shared';
import { CouplingsBar } from './couplingsBar';
import { useRPC } from '@rrox/api';

Expand Down Expand Up @@ -45,14 +45,14 @@ export function FrameControls( {

const { type, controls: controlsData, boiler, compressor, tender, speedMs, maxSpeedMs } = selectedData || {};

const definition = FrameDefinitions[ type ];
const definition = FrameDefinitions[ type ] ?? FrameDefinitions[ FrameCarType.UNKNOWN ];
const isEngine = definition.engine;

const [ pendingSyncControls, setPendingSyncControls ] = useState<boolean | null>( null );

useEffect( () => {
if( pendingSyncControls !== null && pendingSyncControls === data.syncedControls )
setPendingSyncControls( null );
if ( pendingSyncControls !== null && pendingSyncControls === data.syncedControls )
setPendingSyncControls( null );
}, [ pendingSyncControls, data.syncedControls ] );

const [ controls, setControls ] = useState<{
Expand All @@ -74,16 +74,16 @@ export function FrameControls( {

useEffect( () => {
if ( controlsData.regulator === controls.regulator
&& controlsData.reverser === controls.reverser
&& controlsData.brake === controls.brake
&& controlsData.whistle === controls.whistle
&& controlsData.generator === controls.generator
&& controlsData.compressor === controls.compressor )
&& controlsData.reverser === controls.reverser
&& controlsData.brake === controls.brake
&& controlsData.whistle === controls.whistle
&& controlsData.generator === controls.generator
&& controlsData.compressor === controls.compressor )
return;

setControls( controlsData );
}, [ controlsData ] );

const coupledFrames = getCoupledFrames( selectedData, selectedFrame, frames );
const controlledBy = isEngine ? coupledFrames.find(
( coupled ) => coupled.isCoupled && coupled.frame.syncedControls && checkIsEngine( coupled.frame ) && coupled.frame !== selectedData
Expand All @@ -93,7 +93,7 @@ export function FrameControls( {
<div style={{ width: '100%' }}>
{controlledBy
? <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', height: 250 }}>
Controlled by&nbsp;<strong>{`${controlledBy.name.replace("<br>", "").toUpperCase()}${controlledBy.name && controlledBy.number ? ' - ' : ''}${controlledBy.number.toUpperCase() || ''}`}</strong>
Controlled by&nbsp;<strong>{`${controlledBy.name.replace( "<br>", "" ).toUpperCase()}${controlledBy.name && controlledBy.number ? ' - ' : ''}${controlledBy.number.toUpperCase() || ''}`}</strong>
</div>
: <table style={{ width: '100%' }} className='frameControls'>
<thead>
Expand Down Expand Up @@ -191,7 +191,7 @@ export function FrameControls( {
vertical
min={0}
max={100}
value={(controls.generator || 0) * 100}
value={( controls.generator || 0 ) * 100}
step={1}
tipFormatter={( value ) => value + '%'}
tooltipPlacement={'left'}
Expand All @@ -208,7 +208,7 @@ export function FrameControls( {
vertical
min={0}
max={100}
value={(controls.compressor || 0) * 100}
value={( controls.compressor || 0 ) * 100}
step={1}
tipFormatter={( value ) => value + '%'}
tooltipPlacement={'left'}
Expand Down
3 changes: 2 additions & 1 deletion plugins/map/src/renderer/map/definitions/frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export const FrameDefinitions: { [ key in FrameCarType ]: { image: string | null
[ FrameCarType.TWEETSIE280 ]: { image: Tweetsie280 , imageIcon: Tweetsie280Icon , length: 878.9, engine: true , tender: false, freight: false, name: 'ET&WNC 280' },
[ FrameCarType.TWEETSIE280_TENDER ]: { image: Tweetsie280Tender , imageIcon: Tweetsie280TenderIcon , length: 618.8, engine: false, tender: true , freight: false, name: 'ET&WNC 280 Tender' },
[ FrameCarType.COACH_DSPRR_1 ]: { image: COACH_DSPRR_1 , imageIcon: COACH_DSPRR_1Icon , length: 980.8, engine: false, tender: false, freight: false , name: 'Coach DSPRR' },
[ FrameCarType.LIMA280 ]: { image: Lima280 , imageIcon: Lima280Icon , length: 878.9, engine: true , tender: false, freight: false, name: 'Lima 280' },
[ FrameCarType.COACH_DSPRR_2 ]: { image: COACH_DSPRR_1 , imageIcon: COACH_DSPRR_1Icon , length: 980.8, engine: false, tender: false, freight: false , name: 'Coach DSPRR' },
[ FrameCarType.LIMA280 ]: { image: Lima280 , imageIcon: Lima280Icon , length: 878.9, engine: true , tender: false, freight: false, name: 'Lima 280' },
[ FrameCarType.LIMA280_TENDER ]: { image: Lima280TenderIcon , imageIcon: Lima280TenderIcon , length: 615.8, engine: false, tender: true , freight: false, name: 'Lima 280 Tender' },
[ FrameCarType.PLANTATIONCAR_FLATCAR ]: { image: Plantationcar_Flatcar , imageIcon: Plantationcar_FlatcarIcon , length: 331.2, engine: false , tender: false, freight: true, name: 'Gregg Sugar Cane Cane Flat' },
[ FrameCarType.PLANTATIONCAR_FLATCAR_LOGS ]: { image: Plantationcar_Flatcar_Logs , imageIcon: Plantationcar_Flatcar_LogsIcon , length: 331.2, engine: false , tender: false, freight: true, name: 'Gregg Sugar Cane Logging Flat' },
Expand Down
32 changes: 16 additions & 16 deletions plugins/map/src/renderer/map/elements/frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const Frame = React.memo( function Frame( { data, index, frames }: { data

const { location, rotation, type, freight, number, name, controls } = data;

const definition = FrameDefinitions[ type ];
const definition = FrameDefinitions[ type ] ?? FrameDefinitions[ FrameCarType.UNKNOWN ];

const teleport = useRPC( TeleportCommunicator );
const framecarReset = useRPC( FramecarResetCommunicator );

const framecarReset = useRPC( FramecarResetCommunicator );

const [ controlsVisible, setControlsVisible ] = useState( false );
const [ storageVisible, setStorageVisible ] = useState( false );
Expand Down Expand Up @@ -84,12 +84,12 @@ export const Frame = React.memo( function Frame( { data, index, frames }: { data
{follow.following?.array === 'frameCars' && follow.following.index === index ? 'Unfollow' : 'Follow'}
</Button>
{popupElements}
{settings.features.resetFramecars && <Button
style={{ marginTop: 25 }}
onClick={() => {
framecarReset( index );
}}
>Reset Framecar Location</Button>}
{settings.features.resetFramecars && <Button
style={{ marginTop: 25 }}
onClick={() => {
framecarReset( index );
}}
>Reset Framecar Location</Button>}
</MapTooltip>
<FrameControlsPopup
title={`${name.replace( "<br>", "" ).toUpperCase()}${name && number ? ' - ' : ''}${number.toUpperCase() || ''}`}
Expand Down Expand Up @@ -119,7 +119,7 @@ export const Frame = React.memo( function Frame( { data, index, frames }: { data
rotation={Math.round( rotation.Yaw ) - 90}
color={getStrokeColor( controls.brake )}
fillColor={definition.freight
? preferences.colors[ type as FreightFrameCarType ][ freight && freight.currentAmount > 0 ? (freight && freight.currentAmount == freight.maxAmount ? 'fullyloaded' : 'partiallyloaded') : 'unloaded' ]
? preferences.colors[ type as FreightFrameCarType ][ freight && freight.currentAmount > 0 ? ( freight && freight.currentAmount == freight.maxAmount ? 'fullyloaded' : 'partiallyloaded' ) : 'unloaded' ]
: preferences.colors[ type as EngineFrameCarType ]}
fillOpacity={1}
interactive
Expand All @@ -142,12 +142,12 @@ export const Frame = React.memo( function Frame( { data, index, frames }: { data
}}
>Show Freight</Button>}
{popupElements}
{settings.features.resetFramecars && <Button
style={{ marginTop: 25 }}
onClick={() => {
framecarReset( index );
}}
>Reset Framecar Location</Button>}
{settings.features.resetFramecars && <Button
style={{ marginTop: 25 }}
onClick={() => {
framecarReset( index );
}}
>Reset Framecar Location</Button>}
</MapTooltip>
<FrameControlsPopup
title={frameTitle}
Expand Down
12 changes: 6 additions & 6 deletions plugins/map/src/renderer/map/elements/popupElements/teleport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ export function TeleportPopupButton( props: MapPopupElementProps ) {
const teleportRpc = useRPC( TeleportCommunicator );

const teleport = useCallback( () => {
if( props.frame )
if ( props.frame )
teleportRpc( currentPlayerName, {
X: props.frame.location.X,
Y: props.frame.location.Y,
Z: props.frame.location.Z + ( props.frame.type === FrameCarType.CABOOSE ? 0 : 500 ),
} );
else if( props.industry )
else if ( props.industry )
teleportRpc( currentPlayerName, {
X: props.industry.location.X,
Y: props.industry.location.Y,
Z: props.industry.location.Z + 1000
} );
else if( props.sandhouse )
else if ( props.sandhouse )
teleportRpc( currentPlayerName, {
X: props.sandhouse.location.X,
Y: props.sandhouse.location.Y,
Z: props.sandhouse.location.Z + 1000
} );
else if( props.watertower )
else if ( props.watertower )
teleportRpc( currentPlayerName, {
X: props.watertower.location.X,
Y: props.watertower.location.Y,
Z: props.watertower.location.Z + 1000
} );
}, [ currentPlayerName, props.frame, props.industry, props.sandhouse, props.watertower, teleportRpc ] );

if( !settings.features.teleport || ( !props.frame && !props.industry && !props.sandhouse && !props.watertower ) )
if ( !settings.features.teleport || ( !props.frame && !props.industry && !props.sandhouse && !props.watertower ) )
return null;
if( props.frame && !isEngine( props.frame ) && props.frame.type !== FrameCarType.CABOOSE && props.frame.type !== FrameCarType.WAYCAR && props.frame.type !== FrameCarType.COACH_DSPRR_1 )
if ( props.frame && !isEngine( props.frame ) && props.frame.type !== FrameCarType.CABOOSE && props.frame.type !== FrameCarType.WAYCAR && props.frame.type !== FrameCarType.COACH_DSPRR_1 && props.frame.type !== FrameCarType.COACH_DSPRR_2 )
return null;

return <Button
Expand Down

0 comments on commit ba70029

Please sign in to comment.