logo
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Unfinished Language features. (Read 954 times)
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 595
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Unfinished Language features.
Jan 26th, 2015 at 10:12am
Print Post  
UnrealScript language features like an FArray/TMap interface is sth. which seems to be at least supported by some degree by the script compiler, so I tinkering with the idea of trying to experimenting with runtime support for this (e.g. add needed native functions, which are hooked in to some degree).

However as I've never touched this before and actually doesn't have a list of these features I'm asking you guys if you can name the things you know of. This doesn't have to be DeusEx specific, but rather for any unreal 1 game, so i have an idea what i can try and what probably fails.
  

HX on Mod DB. Revision on Steam. Löffels on Patreon.
Back to top
 
IP Logged
 
.:..:
Oldunreal MasterPoster
Developer Team
*
Offline



Posts: 1534
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: Unfinished Language features.
Reply #1 - Jan 26th, 2015 at 2:52pm
Print Post  
FArray is base class of TArray.
TArray is dynamic array object in C++ codes, as for TMap, it is hash mapping for paired values, for example:
TMap<FString,UClass*>, can be used to quick find a matching class reference with a string.

Dynamic array support is broken in UnrealScript on UnrealEngine 1.
Map is fully unsupported in UnrealScript on all UnrealEngine versions.
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
IP Logged
 
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 595
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Re: Unfinished Language features.
Reply #2 - Jan 26th, 2015 at 4:02pm
Print Post  
Actually i wanted to type TArray, not FArray.
I know that TArray support is broken, but i just saw TArrayNoInit in Brother Bear, and actually DeusEx has sth like this in it's uc source, but i seems to be just used to have a struct of the right size in place:
Code
Select All
// ----------------------------------------------------------------------
// UnrealScript version of TArray/FArray (originally in Object.uc; moved
// here after removal in version 224)
struct DynamicArray
{
	var const int Num, Max, Ptr;
};
var const native DynamicArray displayBuffer;
 


And as BrotherBear uses a different syntax anyway e.g.
Code
Select All
var array<Actor> AuxAnims;
 


However at some time i read sth. about broken script compiler features refering TArray and iirc even TMap stuff, that the script compiler at least notices a bit of it's syntax and stuff. However, the question i want to investigate is if the compiler actually compiles some of that TArray related code and if he does, did he create opcodes for it? If it does that i could try adding a function to GNatives implementing that functionality. Iirc i saw that Brother Bear had two hardcoded names, added exec's or sth. (can't find it again right now) comparted to ut432 which sounded like TArray support, but actually it did had the first of a set of three functions which sounded like sth which is used to access an TArray. So I'm hoping that the compiler actually creates an opcode for it, hence I'm asking for detailed info about what is already known, so I don't have to start from scratch.
  

HX on Mod DB. Revision on Steam. Löffels on Patreon.
Back to top
 
IP Logged
 
.:..:
Oldunreal MasterPoster
Developer Team
*
Offline



Posts: 1534
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: Unfinished Language features.
Reply #3 - Jan 27th, 2015 at 2:56pm
Print Post  
Well the pre-224 version with "DynamicArray" struct has absolutely no UnrealScript support for dynamic arrays.

224 and later UScript compiler does produce compiled code for array entry accessor, but the native function itself is unimplemented, so if you want you CAN actually override that GNative entry to a fixed version of the accessor:
Code (C++)
Select All
GNatives[EX_DynArrayElement] = &MyCustomObject::execCustomArElement; 


That way this will be functional:
Code
Select All
var array<int> A;
A[0] = 25; 


But you will still need to implement your own native function to modify array size.
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
IP Logged
 
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 595
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Re: Unfinished Language features.
Reply #4 - Jan 27th, 2015 at 4:18pm
Print Post  
Thanks!
Does the static array accessor do proper bounds check? Probably not.. as it will try to access UFixedArrayProperty::Count, which is inside the alignment/padding following the UArrayProperty. So i guess i should start with trying to implement a save version of it, which behaves like the static accessor if out of bounds.
  

HX on Mod DB. Revision on Steam. Löffels on Patreon.
Back to top
 
IP Logged
 
.:..:
Oldunreal MasterPoster
Developer Team
*
Offline



Posts: 1534
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: Unfinished Language features.
Reply #5 - Jan 27th, 2015 at 8:58pm
Print Post  
You can rather easily find UE source codes with google, from there you can see how it's implemented.
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
IP Logged
 
Higor
New Member
Betatester
Developer Team
*
Offline


Oldunreal member

Posts: 49
Location: Behind you
Joined: Oct 21st, 2014
Gender: Male
Re: Unfinished Language features.
Reply #6 - Mar 3rd, 2015 at 5:12pm
Print Post  
Given i'm not a licensee or anything, am I allowed to post what I used in XC_GameEngine to add dynamic array support for UT?
Even if I made unrealscript code compiled with it cross-compatible with 227?
  
Back to top
 
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3214
Joined: Aug 7th, 2011
Gender: Male
Re: Unfinished Language features.
Reply #7 - Mar 4th, 2015 at 8:13am
Print Post  
As far as I'm concerned, if it's doable in public headers using your own code, it's fine.

Unrealscript for U1 probably generates the same opcodes for generating dynamic arrays as UT. I dont think the compiler for 227 was changed to support dynamic arrays further, only native functions to access TArray<> functions.
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 8100
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Unfinished Language features.
Reply #8 - Mar 4th, 2015 at 11:30am
Print Post  
as for 227, well, we have some additions, dots really did a good job there... Smiley

Quote:
Dynamic Array support has been improved:

Added dynamic array length accessing functions: native(640) static final function int GetArraySize( ArrayProperty ArProp ); native(641) static final function bool InsertArrayIdx( ArrayProperty ArProp, int Offset, optional int Count ); native(642) static final function bool RemoveArrayIdx( ArrayProperty ArProp, int Offset, optional int Count );

static native(238) final function string Locs( string InStr ); native(239) static final function string ReplaceStr( string Text, string FindStr, string ReplaceWith, optional bool bCaseInsensitive ); native(240) static final function bool SortArray( ArrayProperty Prop, Function SortCode ); native(241) static final function bool SortStaticArray( Property Prop, Function SortCode, optional int SortSize ); Which does convert string to lower case, replace part of some string, sort dynamic and static arrays (in a very performance effective way).

Added new defaultproperties macros for dynamic arrays: Array.Add(Value), Array.Remove(Value), Array.Empty


Higor wrote on Mar 3rd, 2015 at 5:12pm:
Given i'm not a licensee or anything, am I allowed to post what I used in XC_GameEngine to add dynamic array support for UT?
Even if I made unrealscript code compiled with it cross-compatible with 227?

as long its based on public headers as Casey already said, everything is fine.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 595
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Re: Unfinished Language features.
Reply #9 - Mar 11th, 2015 at 6:04pm
Print Post  
Not directly an unfinished feature, but i wrote a simple hack for script include support:
Code
Select All
// Stripped of everything which would need other depencencies.
struct FFeedbackContextAnsi : public FFeedbackContext
{
	// Variables.
	INT SlowTaskCount;
	INT WarningCount;
	FContextSupplier* Context;
	FOutputDevice* AuxOut;
};
extern DLL_IMPORT class WLog* GLogWindow;

UBOOL URevisionEditorEngine::SafeExec( const TCHAR* Cmd, FOutputDevice& Ar )
{
	const TCHAR* Str = Cmd;

	// Hack for #exec include.
	if( ParseCommand(&Str,TEXT("INCLUDE")) )
	{
		if ( GLogWindow )
		{
			Ar.Logf( NAME_ExecWarning, TEXT("Include command not supported inside UnrealEd.") );
			return 1;
		}
		FString File, Text;
		if ( !Parse(Str,TEXT("FILE="),File) )
		{
			Ar.Logf( NAME_ExecWarning, TEXT("No include file specified."), *File );
			return 1;
		}
		if( !appLoadFileToString( Text, *File ) )
		{
			Ar.Logf( NAME_ExecWarning, TEXT("Include file %s not found."), *File );
			return 1;
		}

		// TODO: Find another way to aquire ScriptCompiler.
		//       Right now assumption is made that if GLogWindow==NULL
		//       GWarn is an FeedbackContextAnsi. MEGA-BARF.
		FFeedbackContextAnsi* AnsiWarn  = (FFeedbackContextAnsi*)GWarn;
		FScriptCompiler* ScriptCompiler = (FScriptCompiler*)AnsiWarn->Context;
		UClass* Class = ScriptCompiler->Class;

		// Split Script text in part before #exec include and after.
		FString Left, Right;
		INT Start;
		Left  = Class->ScriptText->Text;
		Left  = Left.Left( ScriptCompiler->InputPos );
		Start = Max(Max(Left.InStr(TEXT("\r"),1),Left.InStr(TEXT("\n"),1))+1,0);
		Left  = Left.Left( Start );
		Right = FString( ScriptCompiler->Input+ScriptCompiler->InputPos );

		// Hook in changed ScriptText.
		Class->ScriptText->Text  = Left+TEXT("\r\n")+Text+Right;
		ScriptCompiler->Input    = *Class->ScriptText->Text;
		ScriptCompiler->InputLen = Class->ScriptText->Text.Len();
		ScriptCompiler->InputPos = Start;
		return 1;
	}
	else
		return Super::SafeExec( Cmd, Ar );
}
 



So now one can do sth. like this:
Code
Select All
#exec include file="Classes\Test.inc"
 

  

HX on Mod DB. Revision on Steam. Löffels on Patreon.
Back to top
 
IP Logged
 
han
Global Moderator
Unreal Rendering Guru
Developer Team
*****
Offline


Oldunreal member

Posts: 595
Location: Germany
Joined: Dec 10th, 2014
Gender: Male
Re: Unfinished Language features.
Reply #10 - Nov 12th, 2015 at 1:41am
Print Post  
I just had a wicked idea how to hack in features to the script compiler. E.g. if you compile a map declaration the uc compiler throws an exception. So basic idea is to attach some kind of debugger to the process, use it to run own code where it had thrown before and afterwards resume at the same position the exception was thrown. Sounds pretty dirty, but might be worth to investigate..
  

HX on Mod DB. Revision on Steam. Löffels on Patreon.