Giter VIP home page Giter VIP logo

opendream's Introduction

OpenDream

OpenDream is a C# project that aims to compile games made in the DM language, and run them.

This project is currently in early stages. Expect bugs, missing features, and a lack of quality-of-life enhancements. Set your expectations accordingly.

All parts of OpenDream should work fine on Windows and Linux, though variability in Linux distributions makes it slightly less likely to work out of the box.

For more information or if you'd like to contribute, join our Discord server.

A detailed description of differences with BYOND can be found here. Note that OpenDream cannot connect to BYOND servers, and BYOND's client cannot connect to OpenDream servers. There is no cross-project compatibility other than being able to migrate from BYOND to OpenDream with minimal effort.

Running

Binaries are available for download under our Releases. If you would rather build from source, see Building.

There's 3 main parts: Compiler, Server, and Client:

Compiler: Run DMCompiler.exe, and pass any number of .dm or .dme files to compile as arguments. Optional arguments can be found here.

Server: Run Robust.Server.exe (OpenDreamServer.exe if built from source) and pass the compiled JSON file you got as a result of running the compiler above as an argument like this: Robust.Server.exe C:/path/to/compiler/output.json

Client: This is only applicable if you built from source, otherwise connect from the SS14 launcher. Run OpenDreamClient.exe. You will be prompted to choose a server address, port, and username. The defaults should work for a locally hosted server.

Building

The first step to building OpenDream is initializing the submodule for the game engine, Robust Toolbox.

To do this, simply run git submodule update --init --recursive in git bash and let it finish.

OpenDream requires .NET 8. You can check your version by running dotnet --version. It should be at least 8.0.0.

To build, one can use a C# compiler (such as MSBuild) to compile the various projects described in the solution. To use the .NET build system, simply run dotnet build -c Release in the OpenDream directory. This will build all of the solutions in release mode and put the resultant binaries in bin

Testing

OpenDream makes use of a unit testing framework. You can run these unit tests by running dotnet test in the OpenDream directory. This will run all of the RobustToolbox tests, as well as the DM language tests which can be found under Content.Tests/DMProject/Tests/. To add to the unit tests, simply create a .dm file under the Tests directory with /proc/RunTest() as the entry point. Optionally you can also add flags to the test, such as // COMPILE ERROR to mark that this test should cause a compile error.

Requests for Comment

New features unrelated to BYOND parity go through an RFC process to solicit input from the wider community. The RFCs and more info on the RFC process can be found here.

Screenshots

The following screenshots are taken from a version of Paradise Station with a recompiled 64-bit rustg DLL. This branch of Paradise is available here.

opendream's People

Contributors

altoids1 avatar amylizzle avatar cyberboss avatar damianx avatar distributivgesetz avatar djiq avatar farseer2 avatar firedhat avatar harryob avatar ike709 avatar insineer avatar itsmeow avatar laboredih123 avatar marksuckerberg avatar martinlyra avatar moonheart08 avatar mumencoder avatar out-of-phaze avatar pali6 avatar paulritter avatar pjb3005 avatar spacemaniac avatar tiviplus avatar willox avatar wixoagit avatar wrexbe avatar zephyrtfa avatar zewaka avatar zonespace27 avatar zumorica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opendream's Issues

Proc/Var declaration blocks aren't handled correctly

/datum
	var
		one = 1
		two = 2

The compiler interprets this as a /datum/var object that overrides variables one and two. What it should do instead is define the variables one and two on /datum.

The same problem exists for proc definitions.

Exception on numbers over signed int32 max value

Example code:

#define BIGNUM 4E9

/proc/is_small_number(x)
    if(x < BIGNUM)
        return 1
    return 0

Error:

Unhandled exception. System.Exception: Expected ')'
   at OpenDreamShared.Compiler.Parser`1.Consume(TokenType type, String errorMessage) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\Parser.cs:line 67
[...]

FILE_DIRs aren't handled

These are optionally used by the Dream Maker IDE but are otherwise useless and can be ignored.

Expected EOF exception in DMParser

Unhandled exception. System.Exception: Expected EOF
   at OpenDreamShared.Compiler.Parser.Consume(TokenType type, String errorMessage) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\Parser.cs:line 62
   at OpenDreamShared.Compiler.DM.DMParser.File() in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\DM\DMParser.cs:line 19
   at DMCompiler.Program.Main(String[] args) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Program.cs:line 38

Tested the compiler against BeeStation after doing a placeholder #if implementation (just SkipIfBody()) and fixing the other open issues. Can't figure out which file is the issue after poking around with the debugger.

Exception in multiline string handling

TG/Bee contains the following code:

/mob/living/simple_animal/hostile/construct/builder
	name = "Artificer"
	real_name = "Artificer"
	desc = "A bulbous construct dedicated to building and maintaining the Cult of Nar'Sie's armies."
	icon_state = "artificer"
	icon_living = "artificer"
	maxHealth = 50
	health = 50
	response_harm = "viciously beats"
	obj_damage = 60
	melee_damage = 5
	retreat_distance = 10
	minimum_distance = 10 //AI artificers will flee like fuck
	attacktext = "rams"
	environment_smash = ENVIRONMENT_SMASH_WALLS
	attack_sound = 'sound/weapons/punch2.ogg'
	construct_spells = list(/obj/effect/proc_holder/spell/aoe_turf/conjure/wall,
							/obj/effect/proc_holder/spell/aoe_turf/conjure/floor,
							/obj/effect/proc_holder/spell/aoe_turf/conjure/door,
							/obj/effect/proc_holder/spell/aoe_turf/conjure/soulstone,
							/obj/effect/proc_holder/spell/aoe_turf/conjure/construct/lesser,
							/obj/effect/proc_holder/spell/targeted/projectile/magic_missile/lesser)
	playstyle_string = "<b>You are an Artificer. You are incredibly weak and fragile, but you are able to construct fortifications, \

						use magic missile, repair allied constructs, shades, and yourself (by clicking on them), \
						<i>and, most important of all,</i> create new constructs by producing soulstones to capture souls, \
						and shells to place those soulstones into.</b>"
						

Notice the whitespace line in playstyle_string. BYOND ignores whitespace lines but OpenDream throws "Expected '"' to end string"

Unable to handle indeterminate number of arguments in macros that isn't named

ex. - the ... specifically

#define TUPLE_GET_1(x) x(_GETTER_1)
#define TUPLE_GET_2(x) x(_GETTER_2)

#define _GETTER_1(a, ...) a
#define _GETTER_2(_, a, ...) a
Unhandled exception. System.Exception: Expected a macro parameter, got: DM_Preproc_Punctuator_Period in: code\datums\pipe_network.dm
   at DMCompiler.Preprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Spess\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 65
   at DMCompiler.Preprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Spess\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 40
   at DMCompiler.Program.Preprocess(String[] files) in C:\Spess\OpenDream\DMCompiler\Program.cs:line 61
   at DMCompiler.Program.Main(String[] args) in C:\Spess\OpenDream\DMCompiler\Program.cs:line 21

CurrentLine doesn't match actual line number

https://github.com/BeeStation/BeeStation-Hornet/blob/master/code/game/objects/items/devices/scanners.dm causes an exception due to #10

WriteSourceAndLine() and the CurrentLine var both say 255. However, the actual problem line is 262.

Looking at the actual lines shows that they are in fact numbered incorrectly. I would say that this is entirely due to multiline strings, but the var/list/dmgreport = list() line doesn't match up either and it's before the multiline.

EDIT: However, there's also some multiline strings earlier in the file that could be contributing to the line number being off. Looks like it might entirely be the fault of multiline strings.

image

Not able to handle complex strings

Not sure which part is unimplemented.

Examples of strings that cause exceptions to throw:

return "[year][seperator][((month < 10) ? "0[month]" : month)][seperator][((day < 10) ? "0[day]" : day)]"

return "[day] day[(day != 1) ? "s":""][hourT][minuteT][secondT]"

hourT = " and [hour] hour[(hour != 1) ? "s":""]"

user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[rustg_url_encode("stats:[REF(stats)]")]")

var/static/regex/bad_chars_regex = regex("\[^#%&./:=?\\w]*", "g")

Instantiating types with non-initial values throws an exception

Example code:
new /obj/item/weapon/pipe{ ptype = 0 }(src.loc)

Exception:

Unhandled exception. System.Exception: Expected dedent
   at OpenDreamShared.Compiler.Parser`1.Consume(TokenType type, String errorMessage) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\Parser.cs:line 67
   at OpenDreamShared.Compiler.DM.DMParser.IndentedProcBlock() in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\DM\DMParser.cs:line 276
   at OpenDreamShared.Compiler.DM.DMParser.ProcBlock() in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\DM\DMParser.cs:line 249
[...]

WriteSourceAndLine() doesn't always output

Exception without file info:

Unhandled exception. System.Exception: Expected '"' to end string
   at DMCompiler.Preprocessor.DMPreprocessorLexer.LexString(Boolean isLong) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Preprocessor\DMPreprocessorLexer.cs:line 233
   at DMCompiler.Preprocessor.DMPreprocessorLexer.ParseNextToken() in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Preprocessor\DMPreprocessorLexer.cs:line 91
   at OpenDreamShared.Compiler.Lexer.GetNextToken() in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\OpenDreamShared\Compiler\Lexer.cs:line 34
   at DMCompiler.Preprocessor.DMPreprocessor.GetNextToken(Boolean ignoreWhitespace) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 219
   at DMCompiler.Preprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 191
   at DMCompiler.Preprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 40
   at DMCompiler.Program.Preprocess(String[] files) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Program.cs:line 61
   at DMCompiler.Program.Main(String[] args) in C:\Users\Ike\Documents\GitHub\OpenDream\OpenDream\DMCompiler\Program.cs:line 21

Unimplemented DMASTVisitor methods

Unimplemented DMASTVisitor methods are the only thing stopping OpenSS13 from compiling, aside from #34 which can easily be sidestepped by modifying the DM code.

However, the DMASTVisitorObjectBuilder and DMASTVisitorProcBuilder go way over my head so I don't think there's many more methods here that I can implement myself.

`\ref(object)` isn't supported

title, something like "\ref(object)"

Unhandled exception. System.Exception: Invalid token '\' in code\procs\logging.dm
   at DMCompiler.Preprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Spess\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 188
   at DMCompiler.Preprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Spess\OpenDream\DMCompiler\Preprocessor\DMPreprocessor.cs:line 40
   at DMCompiler.Program.Preprocess(String[] files) in C:\Spess\OpenDream\DMCompiler\Program.cs:line 61
   at DMCompiler.Program.Main(String[] args) in C:\Spess\OpenDream\DMCompiler\Program.cs:line 21

Possible regression with multiline comments

    if (cellcontrol.var_swap)
			var/airtemp = 0
			/*
			for(var/turf/T in src.FindLinkedTurfs())
				if (istype(T, /turf/space))
					space = 1
					src.airforce = src.oxygen + src.poison + src.n2 + src.co2 + 25000
					src.airdir = get_dir(src, T)
					airtemp = src.temp
					break // *****RM
				else
					divideby++
					total += T.oldoxy
					tpoison += T.oldpoison
					tco2 += T.oldco2
					tosl_gas += T.osl_gas
					ton2 += T.on2
					totemp += T.otemp
					if (T.firelevel >= config.min_gas_for_fire)
						burn = 1
					adiff = src.oldoxy + src.oldco2 + src.on2 - (T.oldoxy + T.oldco2 + T.on2)
					if (adiff > src.airforce)
						src.airforce = adiff
						src.airdir = get_dir(src, T)
						airtemp = src.otemp

			*/
			if(airN)
				if(istype(linkN, /turf/space) && (!config.air_pressure_flow))
					space = 1
					src.airforce = src.oxygen + src.poison + src.n2 + src.co2 + 25000
					src.airdir = NORTH
					airtemp = src.temp

Currently the line if(airN) throws an "Expected dedent" error. Multiline comments in the middle of indented code blocks seem to screw with indent parsing, probably caused by #25

weighted `pick(prob(P); val, ...)` is not implemented

prob(P); Val
  Or
P; Val

example:

pick(5; "foo", 10; "yeet")
Error at code\game\gamemodes\game_mode.dm:63:18: Expected ')'
Error at code\game\gamemodes\game_mode.dm:63:27: Expected dedent
Error at code\game\gamemodes\game_mode.dm:63:27: Expected EOF

potential Float equality issues

Was checking out DreamProcInterpeterOpcodes.IsEqual(), and I noticed there was a few float equality issues that might arise sometime:

return first.GetValueAsFloat() == second.GetValueAsFloat();

There's also two comparisons between integer and float. We should probably check if these are within a certain tolerance ex.

return Math.Abs(first.GetValueAsFloat() - second.GetValueAsFloat()) < TOLERANCE;

I'm not sure the exact tolerance for BYOND's floats. Trying to figure it out currently.

https://github.com/wixoaGit/OpenDream/blob/4c3b9c436efd634d4cfd507c0086f9d5fc8296f9/OpenDreamServer/Dream/Procs/DreamProcInterpreterOpcodes.cs#L1208-L1216

Improper "as" handling

TG/Bee contains the following code:

/procpath
	// Although these variables are effectively const, if they are marked const
	// below, their accesses are optimized away.

	/// A text string of the verb's name.
	var/name as text
	/// The verb's help text or description.
	var/desc as text
	/// The category or tab the verb will appear in.
	var/category as text
	/// Only clients/mobs with `see_invisibility` higher can use the verb.
	var/invisibility as num

It causes an "Expected dedent" exception unless you remove every as (whatever). While the usage of as is pointless, the BYOND compiler doesn't care about its existence.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.