Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2 #62

Open
MggMuggins opened this issue Mar 31, 2017 · 26 comments
Open

D2 #62

MggMuggins opened this issue Mar 31, 2017 · 26 comments

Comments

@MggMuggins
Copy link

I saw a handful of commits that had something to do with D2. I'm currently trying to get Charge to compile using Dmd 2.066. How important is a D2 port?

@Wallbraker
Copy link
Member

Wallbraker commented Mar 31, 2017

I have kind of abandoned charged miners, but feel free to take a look at it. And if you want to copy any code let me know and I can give you what ever license you want.

That said, I completed a port that sits on the d2-port branch. I have ported over the changes on master to the d2-port branch. And I tested the branch with DMD64 D Compiler v2.071.1 on linux and was able to produce a working binary. (Note it crashes when you close the window because the port is still WIP).

If you have any questions feel free to ask.

@MggMuggins
Copy link
Author

Well, I found that branch just after posting this... Anyway, it builds fine using "DMD64 D Compiler v2.071.2", but it crashes with a segfault when you run it. I don't have a D1 compiler, so I'd really like to get D2 functional. You have any insights on this?
I'm pretty new to D, but I've been looking for a project like this for quite a while. If you'd be willing to just stick around and answer my questions, I'd love to work with this program. :P
~Samwise

@Wallbraker
Copy link
Member

Oh right, open up your dmd.conf (should be in /etc/dmd.conf if installed the packaged version) file and remove the flag -export-dynamic. Also make sure you have updated the branch as I just push out two fixes that should help you get further.

I just tried the online mode with classicube and using the direct links I got it working on servers not requiring enhanced mode (Charged Miners is still only a classic client).

Sure I will try and answer and questions, the code is still very D1:ish and programmed mostly by one person quite a few years ago. But should be somewhat cleaner the the average I have no idea what I'm doing project (which I fully admit the code is) I have cleaned the code a little bit to make it more accessible.

@MggMuggins
Copy link
Author

Thanks man. I appreciate your help. What does that flag do? Also, now it seems like it can't find the linker:

LD     Charge
/usr/bin/ld: cannot find : No such file or directory
collect2: error: ld returned 1 exit status
--- errorlevel 1
Makefile:127: recipe for target 'Charge' failed
make: *** [Charge] Error 1```

@Wallbraker
Copy link
Member

No worries. Well that's really weird... does compiling simple programs with gcc work? You might need to install gcc or binutils packages.

@MggMuggins
Copy link
Author

It was compiling just fine before I changed dmd.conf. Here's that:

[Environment32]
DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L

[Environment64]
DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L

@Wallbraker
Copy link
Member

Oh remove that extra -L at the end as well.

@MggMuggins
Copy link
Author

Alright, it builds and runs now! But it's throwing the exception on line 207 of src/charge/util/png.d. And of course only gives me a quit option.

@Wallbraker
Copy link
Member

Have you gotten the latest changes on the branch? I push some changes that should fix that? Also you might need to remove the directory /user/$USER/.config/charge is it probably downloaded the wrong file and can't read it.

@MggMuggins
Copy link
Author

I tried deleting it and it regenerated it. Here is the log file:

<II> Logger: Opened log
<WW> Core: Failed to load settings useing defaults
<II> Core: ODE not found, this not an error.
<II> Core: ALUT not found, this is not an error.
<DD> Core: w: 800 h: 600
<II> Core: Intel Open Source Technology Center
<II> Core: 3.0 Mesa 11.2.0
<II> Core: Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2) 
<II> Core: No joysticks found
<II> ForwardRenderer: Can run forward renderer.
<II> DeferredRenderer: Is not cabable of running deferred renderer!
<DD> DeferredRenderer: object.Exception@src/charge/gfx/deferred.d(327): GL_EXT_geometry_shader4 not supported
----------------
src/charge/gfx/deferred.d:327 [0x68c991]
src/charge/gfx/deferred.d:355 [0x68cb4f]
src/charge/gfx/renderer.d:42 [0x6b685d]
src/charge/platform/core/sdl.d:392 [0x669ba7]
src/charge/platform/core/sdl.d:117 [0x668af5]
src/charge/platform/core/sdl.d:43 [0x668a5d]
src/charge/core.d:87 [0x6f4a01]
src/charge/game/app.d:55 [0x611919]
src/charge/game/scene/app.d:38 [0x618218]
src/miners/game.d:116 [0x484a92]
src/main.d:57 [0x45b96a]
??:? [0x83e062]
??:? [0x83dfac]
??:? [0x83e01e]
??:? [0x83dfac]
??:? [0x83df1d]
??:? [0x46965b]
??:? __libc_start_main [0xa105782f]
<II> Texture: Loaded res/font.png
<II> TextureArray: Can use TextureArrays
<II> MinecraftForwardRenderer: Can run Miners forward renderer.
<II> DoubleTarget: Double target supported (33191)
<II> ColorTexture: created charge/gfx/texture/colorffffffff
<II> ColorTexture: created charge/gfx/texture/color000000ff
<WW> Pool: File not found skin.png
<WW> LoadDefaultSkin: D 1140
<II> Core: Settings saved: 

@Wallbraker
Copy link
Member

Hmm okay, now its failing for me as well.... This is really weird let me look into this as well.

@MggMuggins
Copy link
Author

Fun time. A question on the side: What is the "Correct" way to keep a fork up to date?
~Sam

@Wallbraker
Copy link
Member

Okay, I know what is causing the error. Its the default skin its downloading... But I thought I fixed that. Looking for a new one that will work.

@MggMuggins
Copy link
Author

What are the requirements for a skin that is "Correct"?

@Wallbraker
Copy link
Member

Something that can be loaded by the home brewed image reader I have in Miners... The proper fix for this would probably to use stb_image.h instead of the homebrewed code I got right now.

@MggMuggins
Copy link
Author

Isn't there something in sdl that you could use?

@Wallbraker
Copy link
Member

I tried to keep external dependencies at a absolute minimum to make shipping and bringing new people easier. I'm working on hacking in stb_image.h, got it compiling and need to write some glue code.

@MggMuggins
Copy link
Author

Alright, I'm on standby.

@Wallbraker
Copy link
Member

Well I got it working now with a completely clean config directory and repo so it should work for you now. Sorry for it not working directly out of the box and taking so long for you to start hacking on it.

@MggMuggins
Copy link
Author

MggMuggins commented Mar 31, 2017

Not a problem. The support I recieved was better than just about any other software I can remember. :P

@Wallbraker
Copy link
Member

Hehe thanks, if I wasn't clear it should all work now so you can just go ahead and try the latest changes on the branch.

@MggMuggins
Copy link
Author

Well, it worked alright, although I find the behavior and UI less than appealing (this is why I am going to try hacking the source :P). How did you get the pictures in the README?

@Wallbraker
Copy link
Member

Wallbraker commented Mar 31, 2017

Ah that's the experimental modern Minecraft code that I worked on for a while. While trying to get more people interested in the project I removed as much as possible of the code that was not relevant to what it was being used for, which was a Minecraft Classic client. This was done so people had less code to read and get lost in.

That said you could probably get something similar if you edit the terrain.default.png file that is in the config file. I think the screenshot used the dokucraft texture pack. Also it looks like your graphics card does not support the shadows so that's reason they are missing.

@nahkoots
Copy link

nahkoots commented Mar 21, 2021

I’ve been trying to compile CM recently, partly because I’d like to add support for some classic protocol extensions and partly because the existing releases don’t work for me and I don’t want this software to get lost to time. For reference, I’m using Arch Linux and the d2-port branch. The old versions of the packages I mention are available here:
https://archive.org/details/archlinux_pkg_dmd
https://archive.org/details/archlinux_pkg_libphobos-devel
https://archive.org/details/archlinux_pkg_libphobos (Arch Linux stopped shipping separate development packages at some point, you probably just need these ones)

I tried to compile with the latest DMD first, something like 2.095. Didn’t work, way too many errors and I don’t know enough about D to fix them.

I tried to compile with DMD64 D Compiler v2.071.2 next, because you mentioned 2.0.71.1 worked for you before and that was the closest I could find. That also didn’t work. I got a lot of errors like /usr/bin/ld: /usr/lib/libphobos2.a(deh_win64_posix.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a PIE object; recompile with -fPIE (adding -fPIE to /etc/dmd.conf caused dmd to output that there was no such flag), some errors like /usr/bin/ld: .obj/linux-x86_64/charge/game/update.o: in function `_D3std3utf20__T10byCodeUnitTAxaZ10byCodeUnitFAxaZ14ByCodeUnitImpl4backMNgFNaNbNcNdNiNfZNgxa': /usr/include/dlang/dmd/std/utf.d:3126: undefined reference to `_D3std3utf7__arrayZ', and a smattering of other errors that I’m not going to list (but would be happy to provide).

Finally, I tried to compile with DMD64 D Compiler v2.075.0. This worked the best of all, but still lots of errors. I had to include https://github.com/dlang/undeaD in the build and replace all instances of std.stream with undead.stream and a few others in the source code. I also had to add -L/home/me/undeaD/bin/undead.a to dmd.conf. That made it compile, but when I tried to run the Charge executable I got the following error:

object.Error@src/rt/minfo.d(371): Cyclic dependency between module charge.gfx.texture and charge.gfx.target
charge.gfx.texture* ->
charge.gfx.target* ->
charge.gfx.gl ->
charge.gfx.texture*

A bit of research revealed that DMD improved the cycle detection algorithm in the 2.072.0 release (https://dlang.org/changelog/2.072.0.html, under Library Changes), so that cycle (and I think at least one other) will cause errors from now on. I added –DRT-oncycle=ignore to suppress them, and in return got a single player flat world with some sample blocks and a Herobrine.

Current issues:
I don’t know how to get multiplayer working, but I see that it was supported (even via classicube) so I probably need to look into it more. The launcher doesn't compile for me using msbuild or xbuild, but I haven't looked into it aside from the initial test so it might be an easy fix.
Compiling with 2.075.0 generates a lot of deprecation warnings. Most of them should be pretty easy to solve – e.g. a lot of “module x is deprecated, use y instead” or “Implicit string concatenation is deprecated, use y instead”. I suspect that they’ll turn into errors if I try to compile with the latest DMD, so they’ll have to be fixed at some point.
The biggest issue is that the code doesn’t compile with the newest DMD. Since DMD apparently introduced 5 breaking changes with every release it might be a tremendous hassle to make that happen, but using 3 year old versions of DMD is obviously untenable in the long term.

Wallbraker, would you be willing to put any time into helping me with this? I’m pretty sure I can implement CPE and trim out the old minecraft.net code on my own, but I don’t know enough about D or the structure of Charged Miners to make it compile with the newest DMD.

@Wallbraker
Copy link
Member

@nahkoots Oh that's really good work, thank you for taking a look at this and working through all of those problems. Apologies for not replying earlier. I would be up to try to help you getting it up and running, where is the best way to reach you? Do you have Discord?

@nahkoots
Copy link

No worries at all, thank you for your reply. You can reach me at nahkoots#3280 on Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants