#How to fix my code?
1367 messages ยท Page 2 of 2 (latest)
okay so that just moves the problem
:/
that's still the same thing
local memory after return
you want the fun answer or the easy answer ๐
now the unique ptr error got resolved
just fix the return thing
both?
like
i want to hear about both
the fun answer is chunks should be a unique_ptr not a raw pointer ๐
the easy answer is to throw in the towel and just use shared_ptr
probably instead of unique
(and change chunks back to how it was)
FWIW I think the code you had was correct on other compilers
it seems a weird MSVC bug is stopping it working properly
that doesn't cause error?
I'm an idiot
display world
youre not ๐
auto& sylva = planets[playerPlanet];
change to this
no unique ptr needed on chunks
oops
(although in it, yes)
insert should be fine
you can't copy planets
or you will get that error
but yea, unwind to when that error was causing problems
this is what I had building
vector<vector<vector<unique_ptr<Item> > > > createChunk(string planet, int x, int y) {
//TODO:Actually generating terrain
vector<vector<vector<unique_ptr<Item> > > > a;
a.resize(256);
for (int i = 0; i < 255; i++) {
a[i].resize(16);
for (int j = 0; j < 16; j++) {
a[i][j].resize(16);
}
}
return a;
}
struct Planet {
string name;
unordered_map<string, vector<vector<vector<unique_ptr<Item> > > > > chunks;
vector<vector<vector<unique_ptr<Item> > > >& getChunk(int x, int y) {
string cid = to_string(x) + "," + to_string(y);
auto a = chunks.find(cid);
if (a == chunks.end()) {
chunks.insert({ cid, createChunk(name, x, y)});
return chunks[cid];
}
else {
return a->second;
}
}
probably going to call it a night soon
but am curious to see what you come up with!
bye
(do let me know if that works :P)
in the insert
whats the create chunk signature?
that ampersand is a problem
remove it and the move
you can't make references to local variables and return them
stop it

You two will become besties soon 
no errors now
those numbers are indeed the same
i'll stop throwing spanners into the program โค๏ธ
only took like 6 hours
Tbh anything 3d related usually takes 6 months and not 6 hours so ๐
it's on a console so it's not that 3d yet
Maybe I'd actually learn physics once instead of using the formula book thingy
Segfault :3
ah right

i changed some stuff
it was "air"
now its just null
have to make that change lmao
how do i stop the program from randomly stopping
stop having exceptions?
that's the debugger crashing on an exception usually
or it's hitting a break point
no
What does it say when it stops?
Well there should be a breakpoint then?
but now i found out that if i select a nullptr in the cursorAt=0 then it will break
Hmm maybe some conditional breakpoint that you accidentally enabled
btw i clicked f11 for build
When you press run the ide builds for you and then runs the exe
well good luck! actually going to bed now lol
oof solved a hideous bug
xxx.content==nullptr is a valid statement
but you really intended to write *xxx.content==nullptr
atleast the error rate is less than that of javascript(a weakly typed language or something)
@royal nimbus Please do not send executable files
@royal nimbus Please do not send executable files
Yeah, I also found it to be working one more time: #c-help-text message
And we also found a possible answer: #c-help-text message
today's work
compile it yourself because wheatly thinks that im sending a virus after that account hacking thing /hj
[spoiler]it is not related to the account hacking or anything lol wheatly just hates executables[/spoiler]
I do not have windows, lol
controls:i j k l for pointer movement
b pick up n put down m put down in appropiate slot
space wait
throw away the windows.h related code and try to make your executable run on a ansi compatable application
this kinda sounds like work, what are you actually trying to fix at this point? or are you just wanting a code review?
code review
i did the update thing(confusing because its both the minecraft update and the minecraft schedule tick)
now there are two new items:a pacemaker and a siren
pacemakers schedule themselves as update and update their surroundings
sirens change color when updated
is it supposed to look like this?
well it seems to work anyway
here is the version that worked for me, if you want some sort of cross platform support
I only changed the init function and above besides replacing _getch() with the helper I defined
which brings me to my first bit of code review advice, use a library for console IO
a TUI library
there are a bunch of choices
it's very impressive you figured this all out yourself, but use a library for the love of all that is holy
Curses, FTXUI, Notcurses, etc.
yeah!
also we have a #1078717238678409369 forum here for code review ๐
curses sounds familliar
yeah but i forgot to post it there after posting it here
can you press space a few times and verify there is a siren next to the pacemaker?
I can't see it clearly
if you press space the siren will change color
so i can see it(you can also see it)
well i asked "the intellegence dampening core LLM" (read:chatgpt)lmao
oh another he didnt come and tell me i should use llvm lol
yeah i was wondering it was already 1 day
yes that is good hooray!
if you move the pacemaker it should not break and the siren if nearby should still function
I don't know what these things do ๐
my first part of feedback would be, add more explorable UI
this is dwarf fortress for example
note it has descriptions and help ui for cammnds
it also takes up this huge amount of my termianl for I think no reason
which is annoying ๐
yeah,sorta...
I hardcoded it to be 100x50 because i found out that it worked on my powershell and my screen res
with no consideration of cross platform stuff
i need to figure some stuff...
(not gonna change the 100x50,maybe i will adjust font size or smth)
you can't adjust the font, that's up to the user's terminal ๐
yes, up to users terminal
oh
yea you operating in the very ancient technologies zone
yeah agree
there are commands to read terminal size last I remember
it's okay I found where I can change the W and H
there are commands to read and write terminal size
be warned it might not work fully
also if the numbers are too low you will get a vector index out of range run time error
#define W 50
#define H 30
works much better for me ๐
๐
now you get a rte if an item has more than 11 slots or has a name longer than 50 chars
if you want me to be able to keep easily running it you should make sure to incorporate these changes so next time you send it I can compile it easily
you should fix that
there is a lot of code quality concerns here you should work on really
what is your goal with this
(oh wait the player has more than 11 slots,trigger the bug by pressing o when selected the blue at sign in the middle of the 0 field!)
yeah right
im working on curses stuff
you should also consider putting it on github
so you can track versions and send people links to it
instead of copy pasting the file every time
yeah i've never been used to git stuff
it's pretty straightforward
still wondering about this
what this?
heh wrong order
what is your goal with this project?
making a game
you commit to make a save point, you push to sync that save point with the server
okay, for how long? how far do you plan on going with this?
push commit merge
for...some time
im programming like a feature for like an hour every day
yea, I would say get it in git
that's definitly step 1
then learn how to add libraries, specifically curses, that's step 2
then keep working on it and refactor as you go
the git repository supports step 2, because it will be easier for other people compile your thing if you put the libraries in git
once you add curses it will be harder for you to drop me a file and have me compile it, cause I need the library too
cant get ncurses.h in my ncurses installment?
i downloaded the newest version from gnu
what's make?
you aren't using mingw anymore
omfg its so complicated
you need it in visual studio
yes lol
oh
you probably want cmake
i think i saw cmake yesterday
doing this would be correct if you were on linux lol
so that was a smart idea :p
but you probably want "insall ncurses for visual studio"
I meant as a search phrase 
oh oops
I don't use windows lol
i cant find 2022,i can only find 2017
they don't change that much between versions? depends on how the instructions work
vcpkg is probably the right way to install libraries, yes
be more specific
and also look upt he documentationf or how you are supposed to install this
how di dyou install ncurses
im doing it
probably need to go ask someone who is vcpkg pilled for help?
yeah agree
maybe?
oh wait
my program works perfectly without windows.h
only exception is that flashing cursor at the origin
I mean the point of curses is to make it easier to do terminal programming
not just to fix the cross platform issues
like
like I fixed those with the ifdef stuff already
im not doing terminal programming
you are to draw the screen
im just printing a lot of text with ansi escape
yes and this is called "terminal user interface" or TUI
yeah that link doesn't work
its the same one i talked about assuming no vcpkg
i mean assuming no vs
in retrospect i dunno how this code would help in forcing ansi escape
its not using the dwMode for anything lmao
yeah dk how to use that in vs
you don't you run it from a normal command line
then this step integrates it with your visual studio
you have to start from the beginning
and also cmd window like cmd?
like I linked you a series of 10 instructions ๐
oh ok
you may have to use a different TUI library then
hmm
what tui library then
why am i x64 windows though
(i was not responding bc lunch
hello?mason?
@compact coral ?
cause you are building on windows and have like a 64 bit processor
isnt that x86?
x86 refers to the 32 bit processor, first started with the 8086, sometimes called 386 (hence the X)
ahh okay
most common computer processor instruction set for desktops
probably ftxui?
heard good things about it, seems to be on vcpkg
A site to explore vcpkg with a simple yet powerful search to find all the libraries/packages available.
tagged x64-windows
I am going to bed soon btw
okay
probably not this one...
i just need a way to hide the cursor
and force ansi escape mode
you can do it the way you had it before I suppose, the platform specific one
just use the ifdefs to support multiple platforms
what ifdefs?
compare what I compiled to what you have
lol I dunno what windows has
do
#ifndef _WIN32
char _getch() {
return getchar();
}
#endif
instead then
ifndef is "if not defined
yeah ik
also wouldn't your polyfill make it that you need to press enter every time?
nope, getchar works the way getch does
It seems to be working fine without hitting enter as well too
ah ok
gotta be honest it's been a very long time... like 15 years since I screwed around with this
it may have to do with the other terminal settings I added
yeah
wait what?how old are you and what do you do?
early 30s, independent computer science consultant
oh wow
I did not tamper with display code since the last test(where I was testing about the minus sign feature in the display number function)
however now it has no output for some reason
the last test worked
This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.
!solved
