sortacraft2
sortacraft2
Open website
0
6
SortaGames
SortaGames
This repl has no description
More repls
44comments
to comment
xxpertHacker
xxpertHacker10 months ago

That code is scary for a lot of reasons.

main.js

The array is probably stringified, you might've wanted:

In the onmessage handler on line 21, the if chain should be an if else chain, or a switch case, as multiple can't be true at once.

How about:

There is a heavy overuse of let, a good number of those should be const.

how about

?

Simply seeing this tells me use misused a struct:

Maybe you want a Map?

This is being called more than once? The timeouts will never get cleared, that seems bad, am I missing something?

Also, you can just use:

I'd recommend either pre-declaring keys properties, or using a Map, or a Set

Maybe this would be better as:

vs

or

How about,

vs

Ooh, window mutation is bad.

Is SortaGames accepting new members?

tussiez
tussiez10 months ago

@xxpertHacker Hello! You reviewed my code :DI guess, nobody's asked LOL

Save/load was a test - probably gonna rewrite this too

You can transfer strings? Cool

** is new to me

The numbers in keydown are also a test, (e.g glass)

I'll most likely use Map and Set

Hmmmmmmm

tussiez
tussiez10 months ago

@xxpertHacker For the if statement chain, I also thought of using switch (this is what I should've done if I had more sleep). I would apply all of the changes you've recommended above, but I'm also extremely busy RN (moving) - so later :/

xxpertHacker
xxpertHacker10 months ago

@tussiez Re-read my comment, the last line ;)

I couldn't tell if you responsed to it or not.

Also, I tend to quickly analyze others' code, as I'm used to auditing code before I use it myself, example: whenever I'm about to use a new lib in a project, I'll quickly check it out to make sure it's safe to use.

tussiez
tussiez10 months ago

@xxpertHacker Oh, the line break glitchedYes, I guess it's open (want to join?)

tussiez
tussiez10 months ago

@xxpertHacker Line breaks are broken..

tussiez
tussiez10 months ago
xxpertHacker
xxpertHacker10 months ago

@tussiez Okay, sure, but first, I'd have to ask, how did you and Baconman meet, and how'd you start the project off?

And yes, I always double break, since Repl's md is weird here.

tussiez
tussiez10 months ago

@xxpertHacker1. He made a giant paragraph on recommendations for SortaCraft, then I replied with a couple more, then he did again

  1. This was actually a kinda old idea, I was messing with THREE for a year or so until I finally found a voxel engine that I could build on top of (threejsfundamentals tutorial) - and now I'm here

Ah

xxpertHacker
xxpertHacker10 months ago

@tussiez Well then, sounds nice; I'd be happy to join you two and help out.

What are you two planning to add/do next?

tussiez
tussiez10 months ago

@xxpertHacker A lot - physics, save/load, more biomes, health, mobs, UI

Baconman321
Baconman32110 months ago

@xxpertHacker Ok so C++ server is working (kinda). I am thinking of using C++ for calculations as using nodeJS with two people in it as multiplayer was SLOW AS HECK. Plus, C++ has (I'm pretty sure native. If not, it can support it anyways with a few adjustments or whatever) support for multithreading and so we can have more threads for different servers (of course, we can't have one thread for each server because that would be a nightmare due to overusing threads).

I might need some help with the threading.

PS:Don't take over my job pls

As for the above I was being "semi-serious" but ol markdown won't work ARGH

xxpertHacker
xxpertHacker10 months ago

@Baconman321 I was legit making a threading tutorial using JavaScript :/

In-progress tutorial on threads.

You should only have as many threads as you have CPU cores, on Repl, that'd be 2.

C++ has std::thread.

I already have a multi-threaded Rust++ server working on Repl.

(Rust++ is the name that I gave to my abomination of mixing C++ and Rust)

You will screw up multi-threading, you don't know basic C++, you definately don't know advanced C++.

Threading is advanced; that's no question.

Memory management is hard.

Multi-threaded memory management is as hard as (normal memory management + threading + normal C++) * 1e100.

xxpertHacker
xxpertHacker10 months ago

@tussiez Well then, just invite me; I'll come by and take over Baconman's job in a few hours.

Baconman321
Baconman32110 months ago

@xxpertHacker I know a very little bit of C++.

You will screw up multi-threading, you don't know basic C++, you definately don't know advanced C++.I guess I'll have to learn...

I already got the websocket server up.

Now it's time to learn how to make this thing work....

tussiez
tussiez10 months ago

@xxpertHacker @Baconman321 Huh? two player is slow?

Baconman321
Baconman32110 months ago

@tussiez ? Wdym "two player"?

tussiez
tussiez10 months ago

@xxpertHacker @Baconman321 You said NodeJS multiplayer with two players is slow as heck

Baconman321
Baconman32110 months ago

@tussiez I meant when two players were playing on ur multiplayer previously it was really slow.

Baconman321
Baconman32110 months ago

@xxpertHacker @tussiez lol I'm already beating u to it xxperthacker.

I changed my program and also did a big of configuring on urs tussiez.

Fixed tussiez's use of const scope = this by just binding this (check ChunkGen.js tussiez).

Eh, I should prob relearn JS, but that takes too much time so I'm just going to cache myself using bad code and use better code...

xxpertHacker
xxpertHacker10 months ago

@Baconman321 Well like, I haven't been invited, so what can I do?

Baconman321
Baconman32110 months ago

@xxpertHacker We're at the limit :(

@tussiez can we uninvite that dude who is pending?The buzzbir guy?

Baconman321
Baconman32110 months ago

@xxpertHacker But srsly. Pls don't take me job... :(

I prob expect to come back to the game and see that it's become unrecognizable...

tussiez
tussiez10 months ago

@xxpertHacker @Baconman321 So, hmmmmmThis is because I did a for loop on .setVoxel (smol brain) instead of simply setting world.cells["pos"] to the voxel array, which is infinitely faster

Doing this in a new multiplayer client would make this a LOT faster (no heavy lag, should be just as quick as the singleplayer client)

tussiez
tussiez10 months ago

@xxpertHacker @Baconman321 Sorry I responded really late, I'm filling a moving truck

xxpertHacker
xxpertHacker10 months ago

@tussiez Well, I'm in now. Don't worry about being late, you could've taken an extra day for all I cared.

If there's any specific parts that the team every needs help with, just ping me.

If there's any part of the code that is slightly slower that you think it should be, ping me.

Same applies to if there's any part you want done; I've got plenty of time.

I'll go play around and try to break anything ;)

tussiez
tussiez10 months ago

@xxpertHacker Oke!Can you figure out why when I comment out the WASM code from Methods, the game breaks? It may not anymore though..

xxpertHacker
xxpertHacker10 months ago

@tussiez Checking it out rn :) we should speak there, you can focus on filling that truck or whatever in the meanwhile.

tussiez
tussiez10 months ago
Baconman321
Baconman32110 months ago

@tussiez Can u work in sortacraft with me?

Baconman321
Baconman32110 months ago

@tussiez Can u work in sortacraft with me?

Huh, it cloned... Oh well....

Baconman321
Baconman32110 months ago

@xxpertHacker @tussiez I see you've made another sortacraft repl. Should we revert the changes we made now back to when it worked and use the newely created repl to test code changes that xxprthacker makes?

tussiez
tussiez10 months ago
xxpertHacker
xxpertHacker10 months ago

@Baconman321 Oh, I tried forking to my account; thanks Repl.it.

Baconman321
Baconman32110 months ago

@xxpertHacker Weird. At least in chrome 77 this is valid:

weird.

I mean, why would they allow a variable declarator to be assigned to something?

Should I ask on SO?

Does it work in your chrome version (88 I think u said)?

xxpertHacker
xxpertHacker10 months ago

@Baconman321 It doesn't work because my version of V8 is hacked to only execute JS in strict-mode contexts.

Use strict mode.

Baconman321
Baconman32110 months ago

@xxpertHacker Wait how is that possible?

xxpertHacker
xxpertHacker10 months ago

@Baconman321 How is what possible?

Baconman321
Baconman32110 months ago

@xxpertHacker Making your V8 only execute in strict mode?

I mean, I'm pretty sure you didn't directly change the .exe files...

xxpertHacker
xxpertHacker10 months ago

@Baconman321 Hacked it myself, others have done all kinda of things like this.

Someone change JS functions to direct native functions instead to benchmark performance, for example.

Baconman321
Baconman32110 months ago

@xxpertHacker So do you have to change the source code or do you just have an extension or program that intercepts scripts and adds "use strict" to them or something?

Can you point me to a tutorial on this?

xxpertHacker
xxpertHacker10 months ago

@Baconman321 They don't make tutorials on this stuff, lol.

Just pass --use-strict to V8 on startup.