Guild icon
DDraceNetwork
Development / developer
Development discussion. Logged to https://ddnet.org/irclogs/ Connected with DDNet's IRC channel, Matrix room and GitHub repositories — IRC: #ddnet on Quakenet | Matrix: #ddnet-developer:matrix.org GitHub: https://github.com/ddnet
Between 2023-12-05 00:00:00Z and 2023-12-06 00:00:00Z
Avatar
isnt window.close restricted to only close windows opened by window.open ? (edited)
Avatar
Avatar
meloƞ
isnt window.close restricted to only close windows opened by window.open ? (edited)
Yup, and clicking on a link here on discord calls this function in order to open the link on a new tab
00:35
..in your browser
Avatar
What's the goal of what you are trying to do?
Avatar
Not having to manually close the tab after deciding to open ddnet via steam or standalone.
Avatar
And where is this decision made and how? You told us something about a link here on discord calling a function?
Avatar
0c6978f Support arbitrary number of kernel interfaces, assert on errors - Robyt3 da6dbc9 Merge pull request #7582 from Robyt3/Kernel-Refactoring - heinrich5991
Avatar
Avatar
archimede67
And where is this decision made and how? You told us something about a link here on discord calling a function?
When you click a link on Discord, their JavaScript implementation involves using window.open() to open the designated link. The code I provided is the source code of said link. It redirects the user based on user's choice: standalone, which would be ddnet://${addr} or to Steam, which would be steam://run/412220//${addr}. Essentially, the link runs the application based on the user's selection, and connect the user directly to the server, specified in the {addr} argument.
00:52
Does that make sense? 🙂
Avatar
026ddc3 Extract common expression in variable pSnapshot - Robyt3 93d6691 Use nullptr instead of 0 and 0x0 - Robyt3 8f9a445 Remove unnecessary RangeCheck function - Robyt3 0472808 Add assertions for CSnapshotDelta::SetStaticsize parameters - Robyt3 f5ed415 Mark functions and pointers as const - Robyt3 0ff2c5b Use size_t and add assertions for CSnapshotStorage::Add - Robyt3 3607e8e Merge pull request #7581 from Robyt3/Snapshot-Refactoring - heinrich5991
Avatar
Avatar
murpi
When you click a link on Discord, their JavaScript implementation involves using window.open() to open the designated link. The code I provided is the source code of said link. It redirects the user based on user's choice: standalone, which would be ddnet://${addr} or to Steam, which would be steam://run/412220//${addr}. Essentially, the link runs the application based on the user's selection, and connect the user directly to the server, specified in the {addr} argument.
window.open('', '_self').close(); instead of window.close() (edited)
Avatar
Avatar
meloƞ
window.open('', '_self').close(); instead of window.close() (edited)
Um I don't think so, I believe window.close() works, right @murpi ?
Avatar
aw did i understand the issue wrong again
Avatar
It does, but like I said he code never reaches the stage of actually opening the app because the tab is closed immediately
00:58
The only way I found is to set a timeout, but that's not very elegant 😅 (edited)
Avatar
Yeah, so I don't think there is really a solution to this other than having to wait for a little bit. You could try to detect when the window loses focus and then close it, but that might not work reliably enough
Avatar
I'll give it a try
01:04
That does seem to work quite well 😮 @archimede67 thanks!
Avatar
Avatar
murpi
That does seem to work quite well 😮 @archimede67 thanks!
Oh that's nice 😄 I'm glad it works!
Avatar
Avatar
Ryozuki
any of u tried meson?
I did. it's pretty neat, considered it for ddnet. it advertises rust support, but barely has any (doesn't work with any project using cargo). doesn't have native integration into msvc unfortunately. also depends on python
Avatar
Avatar
Ryozuki
@Learath2 did u learn this at uni btw? https://en.wikipedia.org/wiki/ABA_problem
learned about it
Avatar
Avatar
Chairn
as a teacher, we have no choice to teach C so that students know what's going on under the hood
sounds like rust might also fit
Avatar
Avatar
Chairn
we also teach some assembly
yea, that's actually going under the hood 🙂
Avatar
Avatar
Avolicious
Hello rust devs in here, just a quick question. I would like to move some parts of our network from golang to rustlang. Is tokio-rs still the state-of-the-art tech?
tokio is standard, yes
Avatar
Avatar
Ryozuki
@heinrich5991 @Jupstar ✪ @Learath2 @Chairn quick question do you think its possible to have a functional language allowing low level memory management like C ala malloc, free? with same perfomance as C or Rust
not sure. I guess haskell is the best you'll get?
Avatar
Avatar
Jupstar ✪
well, we could do it like other projects. allow other versions of the game. This as some pros and cons: pro:
  • ppl like Tater can advertise their changes more easy.
  • ppl can decide what they like more
cons:
  • ppl like Tater would take supoprt and maintaining more serious
  • it might split the community at least partially
I like that idea, but deen was opposed to shipping third-party developer's code
Avatar
Avatar
Ryozuki
and we should focus on the core of ddnet
we do. I see none of the core developers focusing on 0.7
Avatar
Avatar
Ryozuki
it would also be easier to support only linux
I'd wager >80% of our player base is not on linux
💀 2
Avatar
Avatar
chillerdragon
It’s not about interest. It’s avoiding the hard fork and uniting the playerbase again
the hard fork was already done by teeworlds
Avatar
Original message was deleted or could not be loaded.
honestly, maybe start by trying teeworlds 0.7 better. if that's impossible, then not much of a point of staying compatible with it
Avatar
Original message was deleted or could not be loaded.
are they? only if the tunes are sent while the demo is recorded, no?
02:33
oof, took a long time to read the backlog
Avatar
Good morning
08:21
It was heinrich rewind time again 😬
Avatar
Avatar
heinrich5991
I like that idea, but deen was opposed to shipping third-party developer's code
I'm also not the biggest fan. Especially for the steam version. If we ever have that sort of launcher you download whatever third party binary you want yourself and put it in there. We should not be involved in that part
Avatar
Avatar
Learath2
I'm also not the biggest fan. Especially for the steam version. If we ever have that sort of launcher you download whatever third party binary you want yourself and put it in there. We should not be involved in that part
To be clear i didn't mean compiled by tater. I meant a side project by ddnet
09:25
I'd never allow third party binaries
09:26
That's also why i wrote, they'd need to take maintaining more serious
Avatar
@Learath2 when u continue aoc
09:38
today is interesting
Avatar
Idk why but after the first couple days I always suddenly get bored
09:38
I'll give it a go today
Avatar
thats why im here
09:39
to make u do it
09:39
ill post rust numbers
09:39
my solutions are regex-less btw
09:39
rust having range types in std is epic
09:40
let src_range = src..(src + len); let dst_range = dst..(dst + len);
Avatar
Also as we keep getting more and more complex questions I won't be able to beat rust anymore 😄
09:41
ohh
09:41
the second part of today needs to be done optimized
09:41
xd
09:41
09:42
i guess its why the 2 randoms havent solved it yet
09:42
ima beat em
Avatar
brownbear 5000fps
Avatar
Avatar
Ryozuki
let src_range = src..(src + len); let dst_range = dst..(dst + len);
oh lol this creates an array ? (edited)
Avatar
a Range<T>
Avatar
ah i'm dumb, for loop example
10:14
for i in 0..10, same concept (edited)
Avatar
today second part is more complex lol
10:14
ranges everywhere
Avatar
tbh I didn't have time to do anything, rip
Avatar
justatest need to fix bugs
SPOILER
Image attachment
Avatar
oh noes
10:26
when the example works but input doesnt
10:26
maybe i should simply bruteforce
Avatar
my bruteforce approach ate all my ram instantly xD
10:44
i solve the example
10:45
and the input solves instantly but its not correct
Avatar
idk for me it worked both, wanna see the code? (py)
Avatar
r u bruteforcing
10:46
im not
10:46
im splitting ranges
10:46
same
Avatar
i guess im missing some split
10:46
GitHub Gist: instantly share code, notes, and snippets.
10:46
maybe u can find it
10:46
xd
10:46
note its not pretty
10:49
the example doesnt go into the branch where a seed range contains more than a whole map range (edited)
10:49
the input does
10:50
but i checked and looks correct
10:50
actually
10:50
maybe a seed range is so big it encompasses 2 map ranges?
10:50
omg
10:51
i think i know
10:52
lucky im using a deque
10:52
i simply can push front the ranges outside
10:52
and i+1
10:52
ok nothing changed
10:52
gg
10:53
oh
10:53
im dum
10:56
YAY
10:56
i did it
10:56
no bruteforcing
Avatar
gj, what was the problem?
Avatar
what i just described
10:57
i wasnt processing again the split ranges outside the mapping
10:57
xd
10:57
here the working
10:58
320.6 µs
10:58
ez
11:00
11:00
im first
11:00
gigachad
Avatar
Avatar
Jupstar ✪
To be clear i didn't mean compiled by tater. I meant a side project by ddnet
yea, was also talking about "compiled by us"
Avatar
Avatar
Ryozuki
rust having range types in std is epic
the range types don't implement Copy which is very annoying
11:14
it infects every struct/enum containing these
Avatar
Avatar
heinrich5991
the range types don't implement Copy which is very annoying
thats true i noticed that xd
11:17
@heinrich5991 do u know why?
11:17
if T is copy
Avatar
because it's implementing iterator and people didn't want it Copy for iterators
11:18
the idea would be to add a lint for it
11:18
but that issue has been open since 2015, I bet
Avatar
Avatar
heinrich5991
yea, was also talking about "compiled by us"
well i also mean maintained by ddnet. just with other restrictions. Maybe by different people than the current code base. By members of the ddnet org. But anyway, my point is not so much about who exactly does it anyway. I'd just like to see different answers to the same question xd
Avatar
This I'm 100% against. People will offload their forks onto us then we'll be pressured into maintaining it forever when the original author gets bored of maintaining it
Avatar
1. as said, maintaining must be taken more serious 2. no, if physics are compatible it can just vanish 3. rn we do exactly that. we maintain old versions bcs exactly 1 person in our team wants it
Avatar
we don't maintain old versions
Avatar
we maintain the backward compability to old versions
11:29
so we maintain it
Avatar
Avatar
Jupstar ✪
we maintain the backward compability to old versions
yes
Avatar
so the coder has to make additional thinking,coding etc. in worst case even start a old client
11:30
=> we maintain old versions
Avatar
Maintaining 4 entire clients is much different than maintaining 1 spaghetti that supports 4 versions
Avatar
no
11:32
ok its different, but not worse
Avatar
I'd also think it's different. maintaining one code base seems a lot easier to me
Avatar
Avatar
heinrich5991
I'd also think it's different. maintaining one code base seems a lot easier to me
but only because you think you have to maintain the other code base too
11:33
i'd say, i'd not maintain ddnet if there is an alternative that is more flexible
Avatar
I'd argue it's worse since the spaghetti usually doesn't need touching. Yes it makes reading the code awful, but as long as you aren't directly touching that part it's fine. An entire fork offloaded to us needs to be kept up to date forever
Avatar
Avatar
Learath2
I'd argue it's worse since the spaghetti usually doesn't need touching. Yes it makes reading the code awful, but as long as you aren't directly touching that part it's fine. An entire fork offloaded to us needs to be kept up to date forever
the problem is. ppl touch it. we often merge half finished stuff (IMHO) which just makes the code even worse
Avatar
Hm, could you remind me of some?
11:35
The recent changes I remember are all either refactors or bugfixes that don't touch any of the backwards compat
Avatar
killmsgs for finishes streamer mode (the way it's done) we often have prediction conflicts between mods i dunno there are so many i can't even list all
11:37
pretty much every new feature is a if branch with 2 ways
11:37
put directly into the code
11:38
it's not designed, it's just coded to work
Avatar
Avatar
Jupstar ✪
so the coder has to make additional thinking,coding etc. in worst case even start a old client
i personally dont start old clients, i dont even test if old clients work i just test the current
Avatar
i basically never touched network code, bcs i feel very uncomfortable touching it
Avatar
Avatar
Jupstar ✪
killmsgs for finishes streamer mode (the way it's done) we often have prediction conflicts between mods i dunno there are so many i can't even list all
Streamer mode I didn't like either ngl. I wouldn't have merged it 😄
Avatar
btw i am not saying the features suck. for me it's about for it interacts with the code base
11:39
just to be clear about that
Avatar
Killmsgs are implemented like this not because of very long backwards compatibility though. Implemented naively they would break even the last version
Avatar
Avatar
Learath2
Killmsgs are implemented like this not because of very long backwards compatibility though. Implemented naively they would break even the last version
but in 2 versions we could remove such code then
Avatar
I think even you don't support breaking every version that isn't the latest
Avatar
well atleast it looks like we got some new devs (?) or it seemed like we got 1 or 2
Avatar
my point isnt about NO backward compability. it's about keeping it for ever
Avatar
cuz it feels like we are all same for years xd
11:40
thats what may truly kill ddnet
Avatar
Avatar
Ryozuki
well atleast it looks like we got some new devs (?) or it seemed like we got 1 or 2
It'll only take one controversial change for them to disappear 😄
Avatar
time to make a monthly pr
11:41
so i feel like i havent abandoned this xd
Avatar
Avatar
Learath2
It'll only take one controversial change for them to disappear 😄
meh, but u gotta go through that kinda
Avatar
Avatar
Jupstar ✪
my point isnt about NO backward compability. it's about keeping it for ever
Tbh, I do agree. We keep way too compatible with ANCIENT versions
Avatar
the problem is new devs usually make features that are BIG CHANGES, or NEW TILES
11:42
and not a simple subtle change
11:42
so obviously they will get lot of talk
Avatar
We support a serverinfo packet that was developed by fstd, for one implementation of ddrace64 that no one has used in 7 years
11:43
drop it
Avatar
howdy fellas
Avatar
hi fellow american
11:43
among europeans
Avatar
midl is making me want to pull my hair out
Avatar
what midl
11:43
lidl?
Avatar
oop was a mistake
11:43
no
Avatar
Or that one hack with "crashmeplx"
Avatar
Microsoft interface design language
Avatar
we dont do that here
11:43
gentoo make language
Avatar
teeworlds kernel actually implement rly similar ideas
Avatar
@Learath2 do u have master track upstream master instead of origin?
11:44
i wanna do that, but im afraid of mistakenly pushing, idk if i can push to main tho
11:44
rn i just git reset with upstream master
11:44
❯ git remote -v origin git@github.com:edg-l/ddnet.git (fetch) origin git@github.com:edg-l/ddnet.git (push) upstream git@github.com:ddnet/ddnet.git (fetch) upstream git@github.com:ddnet/ddnet.git (push)
Avatar
difference between upstream/master and origin?
11:45
they represent the same remote
Avatar
ddnet/ vs edg-l/
11:45
fork moment
Avatar
Avatar
Ryozuki
rn i just git reset with upstream master
git merge upstream/master --ff-only
Avatar
anyway, i'd like to see an alternative on how we handle things anyway. it seems like heinrich and i disagree on pretty much everything sadly. deen said to me, if database is compatible he allows breaking compability. he even gave me a branch in steam to test it out at some point
Avatar
sounds safer than git reset to me (edited)
Avatar
Avatar
Ryozuki
rn i just git reset with upstream master
This is what I do too
Avatar
ChillerDragon BOT 2023-12-05 11:46:25Z
fixed the perma link in an edit btw heinrich
Avatar
git reset --hard upstream/master is a major crutch
Avatar
Avatar
heinrich5991
git merge upstream/master --ff-only
nono, i want to set my master to track upstream/master, so i just do git pull and it does git pull upstream master
Avatar
I never have my master tracking upstream master, it's just unnecessary risk
Avatar
i hope that i finish my first very basic version within the next 4 months. so you'll hear of this idea more often sooner or later from me anyway
Avatar
Avatar
Learath2
I never have my master tracking upstream master, it's just unnecessary risk
thought so
11:47
btw any of u uses ccache
Avatar
I never use bare git pull or bare git push
Avatar
anyone here use nuget with cmake
Avatar
and if the community/moders whatever dislikes it. i am also ok with rq xdd but at least test it out
Avatar
❯ ccache -s Cacheable calls: 26205 / 31963 (81.99%) Hits: 4479 / 26205 (17.09%) Direct: 4129 / 4479 (92.19%) Preprocessed: 350 / 4479 ( 7.81%) Misses: 21726 / 26205 (82.91%) Uncacheable calls: 5758 / 31963 (18.01%) Local storage: Cache size (GB): 8.2 / 50.0 (16.43%) Hits: 4479 / 26205 (17.09%) Misses: 21726 / 26205 (82.91%) this after compiling llvm several times after making my pr
11:47
im just bad at caches right
Avatar
Avatar
heinrich5991
I never use bare git pull or bare git push
I prefer fetch+merge/reset to pull
Avatar
yea, me too
Avatar
Idk what you'd replace with push tho. What do you do?
Avatar
just mean the bare version without any parameters
Avatar
push with*
Avatar
i love that cmake is able to interface with package managers but i do not love how vague it is... i get absolutely no word from the nuget cmake logic but obviously something is going wrong. my project is not finding a header explicitly included in one of my dependency nuget pkgs i set in cmake
Avatar
Ah, yep, never touch those
Avatar
@ChillerDragon code review
11:50
should not fall back to empty string on invalid utf-8, it should probably rather crash
11:50
should not truncate the variable, should rather crash
11:50
i.e. .try_into().unwrap()
Avatar
CStr doesnt do anything on drop right
Avatar
correct
Avatar
unsafe needs to take care of panic safety
11:51
well just return a result
11:51
or option
Avatar
can't, across FFI boundary
Avatar
ah true
11:51
@Ewan option is not ffi safe
11:51
enums itself do quite lot of magic
Avatar
try taking a StrRef instead of a *const c_char
11:52
I explicitly added the type for easy interoparability with C++
Avatar
@heinrich5991 btw do u know how to make a value that cant be initialized in rust
Avatar
Avatar
Ryozuki
@Ewan option is not ffi safe
Is there no wrapper for it in terms of std::optional?
Avatar
that is what i am thinking
Avatar
i learnt this looking at lot of ffi crates
Avatar
Avatar
Learath2
Is there no wrapper for it in terms of std::optional?
i would say c++ std::optional is not ffi safe
11:52
xd
Avatar
Avatar
Learath2
Is there no wrapper for it in terms of std::optional?
doesn't seem so
Avatar
why weird?
Avatar
Avatar
Ryozuki
@heinrich5991 btw do u know how to make a value that cant be initialized in rust
wdym, can't be initialized?
Avatar
@heinrich5991 pub enum MyFFIOpaqueStruct {}
11:53
llvm-sys does this
11:53
u cant initialize this in rust
Avatar
that's probably bad (edited)
11:53
i think cbindgen does it
11:54
llvm-sys is autogenerated
Avatar
because you're telling the compiler that this type cannot be instantiated by anyone
11:54
i.e. if you have an instance, it's instant UB
Avatar
it exists
11:54
i saw some docs
11:54
empty type or smth
11:54
let me search
Avatar
yes
11:54
it's like !
11:54
but you should probably not use it
11:55
Rust also enables types to be declared that cannot even be instantiated. These types can only be talked about at the type level, and never at the value level. Empty types can be declared by specifying an enum with no variants: enum Void {} // No variants = EMPTY Empty types are even more marginal than ZSTs. The primary motivating example for an empty type is type-level unreachability. For instance, suppose an API needs to return a Result in general, but a specific case actually is infallible. It's actually possible to communicate this at the type level by returning a Result<T, Void>. Consumers of the API can confidently unwrap such a Result knowing that it's statically impossible for this value to be an Err, as this would require providing a value of type Void. In principle, Rust can do some interesting analyses and optimizations based on this fact. For instance, Result<T, Void> is represented as just T, because the Err case doesn't actually exist (strictly speaking, this is only an optimization that is not guaranteed, so for example transmuting one into the other is still Undefined Behavior).
11:56
@heinrich5991
One final subtle detail about empty types is that raw pointers to them are actually valid to construct, but dereferencing them is Undefined Behavior because that wouldn't make sense. We recommend against modelling C's void* type with *const Void. A lot of people started doing that but quickly ran into trouble because Rust doesn't really have any safety guards against trying to instantiate empty types with unsafe code, and if you do it, it's Undefined Behavior. This was especially problematic because developers had a habit of converting raw pointers to references and &Void is also Undefined Behavior to construct.
Avatar
read on to see the comments I gave against using it like that
Avatar
this is the important part
11:56
raw pointers to them are actually valid to construct
Avatar
yes, because raw pointers don't do anything
11:56
try to use a struct with private fields instead, I guess
Avatar
Avatar
Ryozuki
i would say c++ std::optional is not ffi safe
Well the cxx crate allows stuff like unique_ptr and shared_ptr to make it through. I thought one could similarly translate an Option
Avatar
it's also non-constructible from the outside
Avatar
why would you want this
Avatar
#[derive(Debug)] pub enum LLVMTarget {} pub type LLVMTargetRef = *mut LLVMTarget;
11:57
they do this
Avatar
sounds like a bad idea
Avatar
it's literally ub
Avatar
see above ^^
Avatar
Avatar
Ewan
it's literally ub
its not, because the pointer is returned from c++
Avatar
We recommend against modelling C's void* type with *const Void. A lot of people started doing that but quickly ran into trouble because Rust doesn't really have any safety guards against trying to instantiate empty types with unsafe code, and if you do it, it's Undefined Behavior. This was especially problematic because developers had a habit of converting raw pointers to references and &Void is also Undefined Behavior to construct.
Avatar
this is about rust ffi
Avatar
the same applies to your case
Avatar
its meant to represent a opaque structure
Avatar
yes, and it's a bad idea
Avatar
Avatar
heinrich5991
We recommend against modelling C's void* type with *const Void. A lot of people started doing that but quickly ran into trouble because Rust doesn't really have any safety guards against trying to instantiate empty types with unsafe code, and if you do it, it's Undefined Behavior. This was especially problematic because developers had a habit of converting raw pointers to references and &Void is also Undefined Behavior to construct.
then why do they do it xd
Avatar
I don't know. legacy reasons?
Avatar
well what's the alternative
Avatar
Avatar
heinrich5991
try to use a struct with private fields instead, I guess
.
Avatar
well it seems wasteful
11:58
those fields will never be used. it's the point
Avatar
why is it wasteful to have a field at compile time?
Avatar
ok it doesnt use cbindgen
11:59
idk
Avatar
Avatar
Ewan
well it seems wasteful
rust has zero sized types
12:00
nvm then
Avatar
struct A { b: () }
Avatar
Avatar
Ryozuki
struct A { b: () }
Honestly this looks much sillier to me even if it might be better practice
Avatar
On their own, Zero Sized Types (ZSTs) are, for obvious reasons, pretty useless. However as with many curious layout choices in Rust, their potential is realized in a generic context: Rust largely understands that any operation that produces or stores a ZST can be reduced to a no-op. First off, storing it doesn't even make sense -- it doesn't occupy any space. Also there's only one value of that type, so anything that loads it can just produce it from the aether -- which is also a no-op since it doesn't occupy any space. One of the most extreme examples of this is Sets and Maps. Given a Map<Key, Value>, it is common to implement a Set<Key> as just a thin wrapper around Map<Key, UselessJunk>. In many languages, this would necessitate allocating space for UselessJunk and doing work to store and load UselessJunk only to discard it. Proving this unnecessary would be a difficult analysis for the compiler. However in Rust, we can just say that Set<Key> = Map<Key, ()>. Now Rust statically knows that every load and store is useless, and no allocation has any size. The result is that the monomorphized code is basically a custom implementation of a HashSet with none of the overhead that HashMap would have to support values. Safe code need not worry about ZSTs, but unsafe code must be careful about the consequence of types with no size. In particular, pointer offsets are no-ops, and allocators typically require a non-zero size. Note that references to ZSTs (including empty slices), just like all other references, must be non-null and suitably aligned. Dereferencing a null or unaligned pointer to a ZST is undefined behavior, just like for any other type.
Avatar
Avatar
Learath2
Honestly this looks much sillier to me even if it might be better practice
idk the actual best practice rn
12:00
i need to investigate
Avatar
_non_constructible: () seems about right to me
12:01
you can also do #[non_exhaustive] these days IIRC
12:01
on a struct
Avatar
what does it do
12:01
i guess best practices is whathever cxx generates
Avatar
it's like pretending there's another field you can't name
Avatar
or cbindgen
Avatar
Avatar
Ryozuki
i guess best practices is whathever cxx generates
generally, no
Avatar
*const Void is such an intuitive way to model it except for the facy that you can instantiate empty types with unsafe
Avatar
because code generators can change in the future if there's a problem
12:02
your code won't
12:02
so you shouldn't rely on dodgy tricks
12:02
that work with one compiler version but not with another
Avatar
Avatar
Learath2
*const Void is such an intuitive way to model it except for the facy that you can instantiate empty types with unsafe
fact*
Avatar
I think c_void is actually modeled as an empty struct these days
12:03
Equivalent to C’s void type when used as a pointer.
12:03
hmm, seems to be modeled as a two-value enum
12:03
that sounds super strange ^^
12:04
I guess it could be updated to use the struct variant
12:04
i didnt read correctly
Avatar
but it's easy to get UB
Avatar
it isn't instant UB
Avatar
Avatar
Ryozuki
struct A { b: () }
im wondering why you can't just have some sort of annotation for an explicitly empty structure to represent an opaque struct, where dereferencing results in a panic or smth. unless, that sort of infrastructure is not in place?
Avatar
#[doc = include_str!("c_void.md")] #[lang = "c_void"] #[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435 #[stable(feature = "core_c_void", since = "1.30.0")] pub enum c_void { #[unstable( feature = "c_void_variant", reason = "temporary implementation detail", issue = "none" )] #[doc(hidden)] __variant1, #[unstable( feature = "c_void_variant", reason = "temporary implementation detail", issue = "none" )] #[doc(hidden)] __variant2, } (edited)
Avatar
Avatar
Ryozuki
#[doc = include_str!("c_void.md")] #[lang = "c_void"] #[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435 #[stable(feature = "core_c_void", since = "1.30.0")] pub enum c_void { #[unstable( feature = "c_void_variant", reason = "temporary implementation detail", issue = "none" )] #[doc(hidden)] __variant1, #[unstable( feature = "c_void_variant", reason = "temporary implementation detail", issue = "none" )] #[doc(hidden)] __variant2, } (edited)
Bizarre
12:05
I wonder why the 2 variants
Avatar
Avatar
Ewan
im wondering why you can't just have some sort of annotation for an explicitly empty structure to represent an opaque struct, where dereferencing results in a panic or smth. unless, that sort of infrastructure is not in place?
#[non_exhaustive] pretty much does this, except for the panicking
Avatar
Avatar
Learath2
I wonder why the 2 variants
otherwise it'd be a zero-sized type
12:05
with its own warts
Avatar
#[lang = "va_list"] pub struct VaListImpl<'f> { ptr: *mut c_void, // Invariant over `'f`, so each `VaListImpl<'f>` object is tied to // the region of the function it's defined in _marker: PhantomData<&'f mut &'f c_void>, }
12:05
interesting xd
Avatar
Avatar
heinrich5991
otherwise it'd be a zero-sized type
ah cuz with 1 its optimized right
Avatar
yes
Avatar
Avatar
Ryozuki
#[lang = "va_list"] pub struct VaListImpl<'f> { ptr: *mut c_void, // Invariant over `'f`, so each `VaListImpl<'f>` object is tied to // the region of the function it's defined in _marker: PhantomData<&'f mut &'f c_void>, }
note the #[lang = "…"]
12:07
it means you can't trust what's in there at all
12:07
it's a lang item
Avatar
midl still not cooperating feelsbadman
12:10
this is a microsoft moment
12:10
i leave my app alone and icome back to it the next day and it has some insane build error that i have no idea the origin of
12:11
i hate to generalize so much but this is actually what it's like working anywhere in the ms software sphere
12:11
things just breaking all the time
Avatar
@Ryozuki about best practice btw:
To model pointers to opaque types in FFI, until extern type is stabilized, it is recommended to use a newtype wrapper around an empty byte array. See the Nomicon for details.
Avatar
https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
Notice that it is a really bad idea to use an empty enum as FFI type. The compiler relies on empty enums being uninhabited, so handling values of type &Empty is a huge footgun and can lead to buggy program behavior (by triggering undefined behavior).
The Dark Arts of Advanced and Unsafe Rust Programming
Avatar
llvm-sys is on gitlab
12:13
too lazy to tell them
12:16
@Jupstar ✪ when c++200
12:16
20
Avatar
ChillerDragon BOT 2023-12-05 12:17:38Z
@heinrich5991 i rather have a misaligned menu than a crashed client. Not crashing is nice.
Avatar
well you shouldn't crash xd. you should handle the fault in another way
12:18
in a perfect world
Avatar
ChillerDragon: the idea is that it shouldn't crash. but you should notice when invariants are violated
Avatar
Avatar
Ryozuki
@Jupstar ✪ when c++200
i'm done being a cpp enthusiast. now i ask "when rust nightly" 😬
Avatar
because otherwise you'll hide bugs
12:20
your idea is like stripping out all dbg_asserts in code
Avatar
yes but what does dbg_assert do at the end of the day
Avatar
Avatar
Ryozuki
@Jupstar ✪ when c++200
but yeah, dunno. i think deen gave up for now. which is understandable. ubuntu has other release schedules than debian so his debian distro is newer than the min. ubuntu we target. That's why he tried all the libc hacks, which apparently didnt work out
Avatar
was looking at some small component in ddnet to port to rust
Avatar
=> when old ubuntu drops
Avatar
but idk what to tbh
Avatar
ChillerDragon BOT 2023-12-05 12:22:28Z
i think dbg assert is nice if otherwise you run into bad logic issues. But misaligning a menu is not a bad logic issue. I prefer a stable client in that case.
Avatar
this is how you accumulate bugs
Avatar
Avatar
Ryozuki
was looking at some small component in ddnet to port to rust
could u port jobs
Avatar
without noticing
Avatar
ChillerDragon BOT 2023-12-05 12:22:54Z
yea
Avatar
Avatar
Ewan
could u port jobs
i can try
12:23
gotta learn how the bridge works xd
12:23
idk if the bridge even supports that api rn tho
Avatar
shoud probably not port jobs rn
12:24
Learath2 is working on that part of the code with the async http PR (edited)
Avatar
u could do the http async in rust 😂
Avatar
const unsigned char SERVERBROWSE_GETINFO[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'g', 'i', 'e', '3'}; const unsigned char SERVERBROWSE_INFO[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'i', 'n', 'f', '3'}; const unsigned char SERVERBROWSE_GETINFO_64_LEGACY[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'f', 's', 't', 'd'}; const unsigned char SERVERBROWSE_INFO_64_LEGACY[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'd', 't', 's', 'f'}; const unsigned char SERVERBROWSE_INFO_EXTENDED[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'i', 'e', 'x', 't'}; const unsigned char SERVERBROWSE_INFO_EXTENDED_MORE[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'i', 'e', 'x', '+'}; const unsigned char SERVERBROWSE_CHALLENGE[SERVERBROWSE_SIZE] = {255, 255, 255, 255, 'c', 'h', 'a', 'l'}; (edited)
12:25
we should remove legacy
Avatar
would save you lot of trouble
Avatar
Avatar
Jupstar ✪
u could do the http async in rust 😂
ye its perfect fit xd
Avatar
i think that would mostly come with jobs
12:27
just have to integrate with libcurl
Avatar
Jobs in rust is a bad bad bad idea. Most of the code is in C++ it'd be so annoying to interface
Avatar
i suppose
12:27
its why its simply annoying / rly bothersome to use rust anywhere :7
12:28
which is why we havent done anything in rust
Avatar
Avatar
Ewan
i think that would mostly come with jobs
but jobs are blocking
Avatar
as much as im a pro rust, if we dont do anything with it its better to remove it
Avatar
The http thing could be in rust actually. But someone else should do it. If I rewrite this part of the code once more I'll go insane
Avatar
mastersrv is nice in rust tho
Avatar
Avatar
Jupstar ✪
but jobs are blocking
yes but job scheduler puts them on their own thread i thought?
Avatar
Avatar
Ewan
yes but job scheduler puts them on their own thread i thought?
yep, but it cannot await, yield them
12:29
so u end up blocking a full thread
12:29
c++ has future concept, but we dont use it
12:29
cpp has many many async features
Avatar
Avatar
Jupstar ✪
so u end up blocking a full thread
Actually not all that awful. There is much discussion on whether running many threads and letting the cpu scheduler/kernel take care of it vs having a userspace scheduler
Avatar
that you could make great use of
Avatar
Avatar
Learath2
Actually not all that awful. There is much discussion on whether running many threads and letting the cpu scheduler/kernel take care of it vs having a userspace scheduler
that's true, i also read about this very often.
12:31
but it still means we have to make our jobs different. e.g. by spawning threads or smth
Avatar
it certainly depends on what you’re doing
Avatar
Biggest issue is our jobs api imo. It's not great to use currently
Avatar
bcs they will defs block a thread regardless xD (edited)
Avatar
It'd be nice if we had futures like in folly. With chaining possible on both the same thread or on the calling thread or on a new thread with a nice simple interface powered by templates
Avatar
having to implement a whole class for a new job isn’t awesome. i envision an api where you just give it a function pointer and maybe it has some native thread safe interop. but then i realize this is closer to the c way that we want to avoid
Avatar
imagine having rust send and sync traits
Avatar
embracing cpp features tho u could easily transparently wrap the thread apis so you just pass it a lambda and it’s all inlined. vastly simpler
Avatar
Avatar
Ewan
having to implement a whole class for a new job isn’t awesome. i envision an api where you just give it a function pointer and maybe it has some native thread safe interop. but then i realize this is closer to the c way that we want to avoid
I had a CGenericJob that was a template that could take any function, for a bit, but then I rewrote without it
Avatar
Avatar
Ryozuki
imagine having rust send and sync traits
xdd
12:34
no normal discussions anymore without mentioning rust
12:34
i like that
Avatar
well thats just me being me xd
Avatar
Avatar
Learath2
I had a CGenericJob that was a template that could take any function, for a bit, but then I rewrote without it
feelsbadman
12:34
sleepy just kicked in
12:34
but i cannot sleep until i tame the midl compiler
12:34
and by extension the xaml compiler
12:34
and then my thing will compile
Avatar
I actually have the http thing done but it needs some debugging for a couple things
Avatar
memo: winui is very hard to use with C++ alone, even harder when you leave the bounds of Microsoft’s build system and use cmake. it would genuinely be easier to use C# and a VS solution and just use p/invoke for what im doing. its not worth it
Avatar
I didn't end up touching jobs at all and made http jobs completely separate because noone seemed to like my runners 😄
Avatar
anyone has a easy bug i can fix
12:36
idk what to do
12:37
got 1 hour and half before i go
12:37
sadboi
Avatar
fix my .idl
Avatar
Avatar
Ryozuki
anyone has a easy bug i can fix
Check editor bugs those are usually trivial
Avatar
Avatar
Ryozuki
anyone has a easy bug i can fix
add some test code
Avatar
Avatar
Jupstar ✪
add some test code
if code needs testing it means code is bad 😬
12:38
ok i wanted to make a joke
Avatar
based
Avatar
like ppl who say if code needs comments its bad or smth
Avatar
real coders would not add bugs
12:38
real coders also dont add UB
Avatar
Avatar
Ryozuki
real coders also dont add UB
Me
Avatar
or memory safety issues
12:38
ever
12:38
in their life
12:38
career
Avatar
Avatar
Ryozuki
or memory safety issues
Also me
Avatar
Last time I invoked UB I was 10yo
Avatar
i added a leak in test code when making the pr on llvm XD
12:39
i forgot to add a LLVMContextDispose at end of test code
12:39
the worst is
12:39
their github CI didnt pick it up
12:40
but their buildbot CI did after it merged
12:40
so they did a reverse
12:40
and then fixed
12:40
and back
12:40
xd
Avatar
uff
Avatar
c++ in a nutshell
Avatar
that's why i like RAII
Avatar
yeah i was working with the C api
12:40
not c++
12:40
so i needed to call all those disposes
Avatar
in this case tbf it's not really c++
12:40
u can also leak in rust
12:40
but not as easily
12:41
u kinda leak intentionally or due to using cells wrongly
Avatar
or to give others some work to do
12:41
c++ devs use a lang with lot of ub to give each other more work
12:41
so they can keep working
12:41
and getting their salary
12:42
we solved the mistery
Avatar
stimulate the economy
Avatar
now it makes sense why its mostly old grumpy c++ coders who are against rust holyness
Avatar
im going to lose my mind
12:42
microwave the hard drive visual studio is installed on rn
Avatar
Avatar
Ryozuki
i added a leak in test code when making the pr on llvm XD
intentionally?
Avatar
Avatar
Voxel
intentionally?
not at all lol, i wanted my pr merged and to work since i use that for work
Avatar
why would he sabotage one of the most important open source endeavors owo
Avatar
^ this
Avatar
ryo is imposter
Avatar
im a llvm developer
Avatar
virus in linux kernel next
Avatar
and a rust-lang developer
12:44
owo
Avatar
Avatar
Ewan
why would he sabotage one of the most important open source endeavors owo
probably to test how good code management it had
12:44
why
Avatar
i'm ddnet dev
Avatar
@Jupstar ✪ i once looked into contributing to the linux kernel
12:44
but
Avatar
it looks scary
Avatar
this is what Tests are for
Avatar
im sure they would shout at me
12:44
xd
Avatar
Avatar
Ryozuki
it looks scary
it is
Avatar
Avatar
Ryozuki
if code needs testing it means code is bad 😬
@Ewan
Avatar
Avatar
Voxel
probably to test how good code management it had
they detected the leak with tooling, but it was more late in the infrastructure than expected
Avatar
but i still think that if you really understand the underlaying concepts used in the kernel, c would be the smaller problem
Avatar
llvm is: PR -> CI -> MERGE -> BUILDBOT wiht lot of merges
12:45
the buildbot runs the sanitizers
12:45
idk why CI didnt pick it
Avatar
ngl i wonder how many people tried to sneak in malware when doing a pr but not realizing the code could be seen
Avatar
Avatar
Voxel
@Ewan
This is technically true but it’s satire
Avatar
Avatar
Voxel
ngl i wonder how many people tried to sneak in malware when doing a pr but not realizing the code could be seen
i don't think it is very common, bcs the success rate is simply extremly low
12:48
who does crime if the chance of fail is almost 0
12:48
only trolls
Avatar
ik but the pr page is probably rly funny to look at
Avatar
the chance of success*
Avatar
who wants to play fortnite
Avatar
r u 12?
🤓 1
12:49
who wants to code fortnite
Avatar
Avatar
Jupstar ✪
r u 12?
peter griffin:
Avatar
voxel do u fortnite
Avatar
no but i think the new update is rly funny
Avatar
i can't believe they made him jacked
12:50
all the appeal is gone
12:50
i want to see peter's fat ass waddle across the map cranking 90s
Avatar
they had to shrink his hitbox somehow
12:50
should have just made bullets bounce off his regions that aren't in a normal player hitbox or something
12:50
this is such a copout
12:51
none of the weapons on the map in this season are hit scan and it's super jarring compared to last season where all OG weapons sans snipers are
12:52
i have to actually use my brain and guess where the target will be and account for projectile travel time
12:55
i was a fortnite hater for a long time but tbh fortnite gets a seriously bad rep for no reason other than it's funny to hate on
12:55
it's probably one of the most well rounded, fleshed out video game experiences out there
Avatar
Avatar
Ryozuki
@Learath2 when u continue aoc
I can't pick a language for day 3, help me pick one
13:02
I have the urge to go C ofc, but I also want to do sth different
Avatar
Avatar
Learath2
I can't pick a language for day 3, help me pick one
he already chose one for you
Avatar
Well yeah it's ryo, he'll say rust
13:03
Maybe I'll do rust for a change eventhough it's extremely annoying to work with strings in rust
Avatar
Avatar
Learath2
I can't pick a language for day 3, help me pick one
u want a weird lang?
Avatar
Avatar
Ryozuki
u want a weird lang?
Nah already picked Rust
Avatar
why not sbcl
Avatar
A stack-based array programming language
13:06
try this
Avatar
LOL that is absurd
13:07
someone at work is using it
13:07
for aoc
Avatar
Avatar
Learath2
Nah already picked Rust
good, ur converting
Avatar
Honestly awful to work with ascii strings in Rust
13:11
just use .chars
13:11
chars indices
13:12
it also has many utilities
13:12
split_ascii_whitespace
13:12
etc
13:12
split_once
Avatar
When I know I have ascii strings I just want my nice indexes, no iterators no magic tokenizers
Avatar
mimimimi
Avatar
I know you like your cool space age iterators and functions but I'm a simple man
13:13
I like my state machines and indexes
13:13
but i prefer if u use chars()
Avatar
Avatar
Learath2
I like my state machines and indexes
u can index too
13:14
char indexes
13:14
ok not index like indexing a array
13:15
because utf8
13:15
u could work with bytes but u lose the nice methods
13:15
anyway use .lines() for a iter on lines
13:15
it parses them
13:15
correctly
13:15
unlike u splitting just \n
13:16
An iterator over the lines of a string, as string slices. Lines are split at line endings that are either newlines (\n) or sequences of a carriage return followed by a line feed (\r\n). Line terminators are not included in the lines returned by the iterator. Note that any carriage return (\r) not immediately followed by a line feed (\n) does not split a line. These carriage returns are thereby included in the produced lines. The final line ending is optional. A string that ends with a final line ending will return the same lines as an otherwise identical string without a final line ending.
13:17
let numbers = lines .next() .unwrap() .split_once(": ") .unwrap() .1 .split_ascii_whitespace() .map(|x| x.parse::<u64>().unwrap()) .collect_vec(); lines.nth(1);
Avatar
Avatar
Ryozuki
unlike u splitting just \n
Splitting on \n is completely fine for C
Avatar
this is how i parsed the input on last day
13:17
well its t he first line
Avatar
Avatar
Learath2
Splitting on \n is completely fine for C
yeah but there are subteities
13:17
like empty last line, carriage shit etc
Avatar
In text mode libc handles the CRLF/LF
13:18
I hate that CRLF is still a thing btw
feelsbadman 1
13:18
winshit
Avatar
Why can't microsoft just be normal?
13:18
It's over this isn't 1856, we don't have carriages that require return anymore
Avatar
Bro still computing like we have teletypes
Avatar
tell them that
Avatar
If only they'd listen to me
Avatar
If Microsoft wanted an OS built on sane principles they could just use UNIX. Most probably they don't.
Avatar
maybe the execution is bad but the principles are solid… no pun intend even though i was just pulling my hair out over midl
13:23
most of their issues stem from lack of attention imo
Avatar
What principles? Principle of cornering the market with a monopoly?
Avatar
lately in win 11 most of the issues have been corporate side or in the shell where there are 20 different teams all with different goals trying to exist in parallel
13:23
at a low level it seems like their tooling suffers from lack of clarity when something goes wrong
13:23
and it's a little convoluted
Avatar
There is only one nice thing I can say about how windows/nt kernel is built and it's their extremely well made forwards/backwards compatibility
Avatar
holy shit this update is so unstable
13:24
this is like the fifth crash
13:24
all top10 games
13:24
feelsbadman
Avatar
Avatar
Learath2
What principles? Principle of cornering the market with a monopoly?
A Windows 10 install requires 30GB of disk space, that's not a bug it's a feature if you wanna sell stuff
13:25
But that makes the OS bad as an OS.
Avatar
linux update: they add clippy but instead of clippy its that smug ass penguin and they always give you snarky comments
Avatar
Avatar
zogtib
A Windows 10 install requires 30GB of disk space, that's not a bug it's a feature if you wanna sell stuff
what other games do u play that isnt ddnet
Avatar
Avatar
zogtib
A Windows 10 install requires 30GB of disk space, that's not a bug it's a feature if you wanna sell stuff
It's insane what people will tolerate nowadays from companies just because it looks cool
👆 3
Avatar
it’s still more functional in more ways
Avatar
Avatar
Learath2
It's insane what people will tolerate nowadays from companies just because it looks cool
Saying that it "looks cool" might be because of ignorance but practically "normal" ppl, simple people need to actually use Windows.
Avatar
my gentoo server uses like 200mb ram on idle
13:28
and it has 32gb
Avatar
Avatar
Ewan
it’s still more functional in more ways
what ways? linux kernel ships way more drivers than windows
13:29
windows downloads them from virus store
13:30
does winshit has stuff like tempfs
13:30
tmpfe
13:30
cant type
Avatar
Avatar
Ewan
it’s still more functional in more ways
The only reason windows is more functional imo is software vendors not caring about linux and it's relatively small market share enough to port to it
Avatar
Avatar
Voxel
what other games do u play that isnt ddnet
Wine is very nice but it can't run all the games, so having a Windows installation is required if you wanna play some games.
Avatar
If it wasn't for Adobe and some games Windows would have nothing over Linux really
Avatar
im taking that as "i dont have any big games on my pc" (edited)
👍 1
Avatar
Avatar
zogtib
Wine is very nice but it can't run all the games, so having a Windows installation is required if you wanna play some games.
some being the ones using kernel level spy
Avatar
Avatar
Learath2
If it wasn't for Adobe and some games Windows would have nothing over Linux really
adobe my beloved 🤑🤑🤑🤑🤑🏴☠
Avatar
I exclusively boot to windows just for Lightroom and a handful of games
Avatar
i play ffxiv and it runs perfect
13:32
wine has come a long way
13:32
the more vulkan adoption the easier too
13:32
i no longer have a winshit partition
Avatar
Avatar
Ryozuki
wine has come a long way
Issues are usually with the very latest games
Avatar
elden ring ran better
13:32
on Linux
13:32
no stutters
Avatar
Avatar
Learath2
Issues are usually with the very latest games
I tried to get this game running with wine https://en.wikipedia.org/wiki/Bugs_Bunny_%26_Taz%3A_Time_Busters (released around 2000) but it wouldn't work, but worked on Windows
Avatar
BG3 and ER ran great for me too but I had massive issues with RDR2 e.g.
Avatar
me when i am a gamer and i have to play 100gb games
Avatar
Avatar
zogtib
I tried to get this game running with wine https://en.wikipedia.org/wiki/Bugs_Bunny_%26_Taz%3A_Time_Busters (released around 2000) but it wouldn't work, but worked on Windows
Hm, these ancient games usually run just fine on wine. I've had to occasionally use winecfg to get to win98 though
Avatar
Avatar
Learath2
Hm, these ancient games usually run just fine on wine. I've had to occasionally use winecfg to get to win98 though
I tried everything I could, but it failed with a "requires 16 bit desktop" error, even though I used Xephyr ...
13:35
Also I'm not too experienced with debuging wine
Avatar
Debugging wine is an art in and of itself too
😂 1
Avatar
Actually there was a patch fixing it for a similar game but wouldn't work at current wine versions
13:37
so I just used Windows to play the game at that point
Avatar
16bit sounds like dos box
Avatar
Avatar
Ewan
this is like the fifth crash
i have a feeling some windows update or some nvidia driver update causes all my unreal engine games to frequently crash
14:09
mine was perfect before yesterday
14:09
which was when the massive update dropped
14:09
so i think its that lol
Avatar
I think I might not be built for the Rust thinking
Avatar
wtf when did nvidia drivers got bad again
14:09
they were by far the best in past
14:10
back when i was young. 2000 years ago
Avatar
Avatar
Learath2
I think I might not be built for the Rust thinking
unlucky you
Avatar
How hard can it be to just have atoi? Gimme the integer until you get the first bad character, it's not rocket surgery, but no I have to find the first bad character myself then give rust only the valid slice which is O(2n) unnecessarily
Avatar
u just need to split at whitespaces
Avatar
Again an extra scan that isn't really required
Avatar
what even is your use case
14:14
i sounds like you actually want serialization
Avatar
nice lie
Avatar
Avatar
Learath2
Again an extra scan that isn't really required
u can use nom
14:15
or libc atoi
14:15
nom is fun
Avatar
let s = "231231...312"; I want s.parse::<i32>() to give me 231231, it's not that difficult, we've been doing it since 1990 no problem
Avatar
Avatar
Ryozuki
u can use nom
nom actually looks very cool, I should give it a try sometime
Avatar
Avatar
Learath2
let s = "231231...312"; I want s.parse::<i32>() to give me 231231, it's not that difficult, we've been doing it since 1990 no problem
but why should this string ever happen in first place
Avatar
leraro can i send something
Avatar
Avatar
Learath2
nom actually looks very cool, I should give it a try sometime
its more oriented for byte than str but works for both niceky
Avatar
Avatar
Jupstar ✪
but why should this string ever happen in first place
It's part of the AOC input for day 3
Avatar
u can also go overboard and so a LR parser with lalrpop
Avatar
Avatar
Learath2
It's part of the AOC input for day 3
ah ok, so a puzzle
Avatar
Avatar
Jupstar ✪
ah ok, so a puzzle
It's not extremely unusual in non puzzle cases too. There is a reason strtol is defined the way it is
💯 1
Avatar
i would show u but im at gym
Avatar
Avatar
Learath2
It's not extremely unusual in non puzzle cases too. There is a reason strtol is defined the way it is
i'd say it's very bad to use such strings. in these cases u probably want serialization
Avatar
for(;;) { int k = strtol(s, &s, 10); while(*s++ == ',' || s == ' '); // do sth with k } (edited)
Avatar
why would one work with this
Avatar
CSV is extremely common, there you go a very trivial way to parse csv
Avatar
i'd split by comma and maybe trim
Avatar
i hate mobile
Avatar
but why should it have strings mixed with numerics
Avatar
I mean if you never write a parser ever, yes it's not the most useful thing ever, but when writing parsers you commonly want to nom parts of the input, which is why an entire rust crate exists around the usecase
14:21
LR parsers also work on the same idea, go left to right, accept the most you can
Avatar
Avatar
Learath2
I mean if you never write a parser ever, yes it's not the most useful thing ever, but when writing parsers you commonly want to nom parts of the input, which is why an entire rust crate exists around the usecase
this is simply not true. the reason it exists is bcs someone thought it's so clever to mix chars and ints and call it a good awesome parsable data structure xDD
14:22
a parser is also for serialized data, and there it should, if your serializer works right, never happen
Avatar
Ok, you are the smartest, decades of computer science and no one thought of it
Avatar
Avatar
Learath2
Ok, you are the smartest, decades of computer science and no one thought of it
thanks
Avatar
there is a idiom common in rust, unrelated maybe but i remembered
14:22
parse, dont validate
14:23
or smth like that
Avatar
this is a rust thing ?
14:24
its a common idiom
14:24
but easier or only able to do in strongly typed langs
Avatar
@Learath2 i even bet that, e.g. using a space can be faster, because you can split the work more easily, since you only have to look out for spaces
Avatar
It's not even just numeric and alphanumeric btw, this is literally how most parsers for context free languages are built, build tokens by accepting from the left until you can't
Avatar
i dunno, i'd say most of these probably use a binary format but if not. i'd still not recommend it. what would be the use case over a structured format, or any delimeter or whatever
Avatar
How do you think split works?
14:27
It's not rocket science, it accepts stuff until your delimeter
Avatar
yeah but just that this splitter exists, makes it 10000 times better
Avatar
If you first split, then parse the integer you are just wasting cycles
Avatar
than just "2121hiwazzupbroParseMe231"
Avatar
Avatar
Learath2
If you first split, then parse the integer you are just wasting cycles
depends on the split. if it's part of the iterator then not
Avatar
(and not only the case with integers, anything you can parse LR with a scan, if you split first you are wasting time)
14:29
Yeah, if it has iterator magic it's fine
14:31
And even then only in the case of the correct kind of iterator magic, in Java iirc it'll end up building strings and passing it on, double scanning
14:31
Spliterator iirc it was called
Avatar
but in theory it can still make sense.. but tbf it depends on context. if u have a huge string u could easily split tasks. u have one extra scan, but therefore the substrings can directly be pushed to a thread or whatever. Depends on the complexity of your struct, but could have use cases
Avatar
Avatar
fokkonaut
leraro can i send something
I missed this, what did you want to share?
Avatar
why did i knew this happens
Avatar
probably because you are smart
Avatar
ah right. i am the smartest dev alive
Avatar
Arguably
Avatar
learath gave me this honor
Avatar
Avatar
Jupstar ✪
ah right. i am the smartest dev alive
Knuth has nothing on you
Avatar
Avatar
Learath2
Yeah, if it has iterator magic it's fine
i think with iterators its optimized
14:45
the power of lazy
14:45
or maybe not
14:45
idk
Avatar
Avatar
Ryozuki
i think with iterators its optimized
It could be in Rust, idk how split works under the hood in rust
Avatar
it returns a iterator ofc
Avatar
How would it know how much to pass on to parse if it doesn't pre-scan though?
14:46
thats my doubt
Avatar
And parse has to scan again when building the integer, idk
Avatar
Avatar
fokkonaut
Click to see attachment 🖼️
funniest fokko post
Avatar
Maybe LLVM can see through it?
Avatar
Avatar
fokkonaut
Click to see attachment 🖼️
Don't make me call heinrich on you
Avatar
Avatar
Learath2
Maybe LLVM can see through it?
maybe it could if parse didnt do error checking
14:47
i think its not optimized
14:48
anyway use the itoa simd crate
Avatar
Avatar
Ryozuki
maybe it could if parse didnt do error checking
Anyway, the real CS nerds will point out that O(n) + O(n) = O(n) so it doesn't REALLY matter if you have infinite data
Avatar
Avatar
Ryozuki
anyway use the itoa simd crate
Eh, I don't need it to be that optimal for now. I just used a find to find the first non numeric to implement my own atoi
Avatar
a find?
Avatar
he wants to parse it during finding
Avatar
does atoi guarantee that btw?
14:50
just wondering
Avatar
@Learath2 are u doing the non reverse technique
14:50
ah wait
14:50
its itoa
14:50
no atoi
14:50
xd
Avatar
Avatar
Jupstar ✪
does atoi guarantee that btw?
No guarantee ofc, but why would it ever go through the string twice?
14:51
I know at the very least that glibc goes through it only once
Avatar
Avatar
Learath2
No guarantee ofc, but why would it ever go through the string twice?
dunno, not so smart devs? xdd
Avatar
I took a look at musl and it also goes thru once
Avatar
Avatar
Learath2
Don't make me call heinrich on you
troll
Avatar
uclibc, freebsd and XNU too, I won't check any others 😛
Avatar
yeah i doubt anyone does not i was just wondering if it has such a guarantee
Avatar
No, as far as the standard is concerned they could be using a cloud service with workers in southeast asia decoding the ascii strings
Avatar
that's why i'm asking. i wonder if i can use some super computer that just takes every character as single instance and then checks if it's digit or not
14:58
and ofc go into a python call
Avatar
Avatar
Learath2
No, as far as the standard is concerned they could be using a cloud service with workers in southeast asia decoding the ascii strings
lmfao
Avatar
Avatar
Jupstar ✪
that's why i'm asking. i wonder if i can use some super computer that just takes every character as single instance and then checks if it's digit or not
Yes
Avatar
oups silent overflow
owo 1
Avatar
Avatar
Learath2
I hate that CRLF is still a thing btw
not really. win11 notepad supports LF. CRLF can finally die
Avatar
Avatar
Learath2
let s = "231231...312"; I want s.parse::<i32>() to give me 231231, it's not that difficult, we've been doing it since 1990 no problem
that leads to bad parsing code, usually
15:09
because you don't fail on invalid input
15:09
see e.g. all of the teeworlds code parsing ints
Avatar
And integer overflow xd
15:10
Which kinda is invalid input tbf
Avatar
and errors in rust
Avatar
heinrich always has logical arguments
Avatar
Nani
Avatar
has anyone ever won heinrich in arguments
15:11
@Jupstar ✪ well atleast it feels like he is right by logic usually xd
Avatar
Avatar
heinrich5991
that leads to bad parsing code, usually
If you don't fail on invalid input that's your mistake, not the function that does exactly what it says it'll do
Avatar
I don't write anything xd
Avatar
If you expect a whitespace after your integer, you confirm the whitespace int k = strtol(s, &s, 10); if(*s != ' ') abort()
Avatar
@Learath2 thats wrong!
15:15
u should use goto
15:15
not abort
15:15
goto to exit
15:15
long jumps
Avatar
im joking cuz he loves goto
15:15
xd
Avatar
goto sympathizer
Avatar
Avatar
Ryozuki
u should use goto
I would but that immediately triggers the "bad code" receptors in heinrich and Jupstar because they read that one article by Knuth in 1453 right after the Ottoman invasion of Constantinople
Avatar
@Learath2 do u use goto that go across function calls?
Avatar
So I save that for my own personal code where other people can't judge me
Avatar
function bodies*
15:16
or calls
15:16
idk
15:16
😂👍
Avatar
Avatar
Ryozuki
@Learath2 do u use goto that go across function calls?
setjmp/longjmp? I only used it once when implementing coroutines in C
Avatar
Avatar
Teero
Hahaha
r u ok
Avatar
Oh, I lie, it wasn't coroutines, it was exceptions
15:18
I gave up on my coroutine implementation, it was far too complex for my level at the time
Avatar
Avatar
Learath2
If you expect a whitespace after your integer, you confirm the whitespace int k = strtol(s, &s, 10); if(*s != ' ') abort()
and you are also supposed to check errno after before someone mentions it, I just omitted it for clarity
Avatar
rust error handling is better
15:19
than errno
15:19
but c doesnt have sum types
Avatar
In an ideal world C would have Result and ? like Rust and we wouldn't need errno and that line would just need a ? instead
Avatar
hehe so u agree
15:19
ferrisBongoHyper
Avatar
Maybe I should make a subset of rust that is just a better C yae_think
Avatar
but in kernel maybe C way is better
15:20
cuz in kernel they need to make sure lot of stuff
15:20
i read some blogs
15:20
its wizardry
15:20
im talking about error handling
Avatar
Eeeeeh, I doubt anyone really enjoys errno
Avatar
well maybe in kernel they would use Result
15:20
but without ?
Avatar
What if linux server was 100% rust, how much time would it need to compile
Avatar
they would take care of errs
Avatar
Yep, that would probably be the case
Avatar
at the call site
Avatar
Linux kernel*
Avatar
Avatar
ReiTW
What if linux server was 100% rust, how much time would it need to compile
probs not much more
Avatar
You have to recover from stuff in the kernel, you can't just pass it upwards, there is nothing upwards
Avatar
Avatar
Ryozuki
they would take care of errs
Who needs error handling? Just write good code???
Avatar
did u know linus now compiles his kernel with clang
15:21
instead of gcc
Avatar
Does it even compile nowadays?
Avatar
clang lacked a couple compiler specific stuff that was blocking
Avatar
@Learath2 btw its me or gentoo stabilizes kernels rly slowly
15:22
15:22
i want SHINY NEW KERNELS
15:22
but i dont want to use testing
15:22
for kernels
Avatar
Yep, they take a bit, you should unmask if you want to be at the bleeding edge
Avatar
i think arch is faster
15:23
at updating kernel
Avatar
Arch just puts it out there without much testing or anything really, if it compiles and the test vm boots they ship
15:23
make oldconfig will show lot of new options
Avatar
That's the unmasked ebuild for gentoo, if it compiles it's there
Avatar
ChillerDragon BOT 2023-12-05 15:37:39Z
shit i spent 2 minutes debugging a fizzbuzz issue -.-
Avatar
@Ryozuki do you have any clue why as_ptr isn't a method for Rc?
15:43
Just curious
Avatar
Avatar
Learath2
@Ryozuki do you have any clue why as_ptr isn't a method for Rc?
U mean why to call it explicitly? (edited)
15:52
Explicit
15:52
Rc::asptr
15:53
Bcs deref
15:53
It can't evaluate it
15:53
At least not always
15:53
I guess
Avatar
I actually don't follow any of that :/
15:54
Currently it's an associated function instead of a method, I was just wondering why that is a better choice than just a normal method
Avatar
Bcs deref
15:55
What if u have vec as type
15:55
Asptr conflicts then
15:55
Vec vs rc
15:55
Rc<vec> i mean
Avatar
Ah, that makes sense, I wonder what the rule is in that case to resolve the issue
16:03
@Ryozuki do you have your aoc solutions up somewhere? I'm curious how you did day 3
Avatar
Can someone suggest a good file recovery tool for Windows. For permanent deleted files?
16:05
Or for ntfs
Avatar
lol what did you do
Avatar
A friend lost his saves because steam cloud was full xD
Avatar
testdisk/photorec works on ntfs
Avatar
photorec is usually your best bet yeah
Avatar
i would recommend the former for that kind of thing tho
Avatar
I read about them but sounded like they can only recover partitions
Avatar
Avatar
Jupstar ✪
I read about them but sounded like they can only recover partitions
No
Avatar
I recovered dozens of photos with photorec on an accidentally formatted sd card
Avatar
And some closed source tool from cclraner did not work
Avatar
photorec just patches files together based on data it sees on a partition
Avatar
Avatar
Ewan
No
Ok
16:07
I never used them so no experience
Avatar
so if it’s game data then it’s gonna make a bunch of weird arbitrary files
16:07
when i did it on my disk i had hundreds of awesome wavs that were not supposed to be wavs
16:07
it’s good for… photos
16:07
testdisk just tries to recover fs journal data afaik
Avatar
Avatar
Ewan
it’s good for… photos
It's good for structured data*
Avatar
It finds wavs everywhere because wavs are just byte arrays that have no structure
16:10
They do technically have structure tho
16:10
Images have headers describing dimensions, chunk type and depth
Avatar
TryInto::<usize>::try_into(p.1).unwrap() this might be the ugliest thing I've ever written 😄
Avatar
Wavs have a p descriptive header
16:10
Depth and length
Avatar
Avatar
Learath2
@Ryozuki do you have any clue why as_ptr isn't a method for Rc?
sry i was cleaning up my apartment
16:10
i was close to being a hobo
❓ 1
Avatar
Enough to hopefully discern the actual boundaries of the file, you’d think. At least the pcm chunk. But no
Avatar
Avatar
Ryozuki
i was close to being a hobo
you should become hobo, you already own anime sword
Avatar
Avatar
Learath2
@Ryozuki do you have any clue why as_ptr isn't a method for Rc?
doesnt it defeat the purpose
16:11
or u mean as unsafe
16:11
@Learath2 why u using rc on day 3 tho
Avatar
Avatar
Ryozuki
@Learath2 why u using rc on day 3 tho
I just misread the task at the start, then patched up something that sort of works, don't worry about it 😄
16:12
day 3
Avatar
Avatar
Learath2
you should become hobo, you already own anime sword
erm i dont own only 1
16:13
i also have the bleach sword and cloud sword, but those are woden
16:13
wooden
16:13
the one i showed is metal
Avatar
https://paste.pr0.tips/fGY?rust here if you want to lose your eyesight, this is only part 1 though
Avatar
ded link ?
Avatar
It loads just fine for me
Avatar
@Learath2 xd a for loop worked
16:14
no need for points
Avatar
for dy in -1i64..2 { for dx in -1i64..2 { // check bounds if (y == 0 && dy < 0) || (y == (height - 1) && dy > 0) || (x == 0 && dx < 0) || (x == (width - 1) && dx > 0) { continue; } let coordy = ((y as i64) + dy) as usize; let coordx = ((x as i64) + dx) as usize; let v = input.get(coordy).and_then(|a| a.get(coordx)).unwrap(); if !v.is_ascii_digit() && *v == '*' && !current_num.is_empty() { is_part_num = Some((coordx, coordy)); } } }
Avatar
Yeah you can just scan through aswell,
16:15
I would have scanned through in C, but in Rust I get brain worms telling me to use weird features
Avatar
@Learath2 a perf tip
16:16
but sometimes it gives trouble with borroows
16:16
let mut row: Vec<Tile> = vec![];
16:16
u can put this outer
16:16
and use .clear
16:16
this way u avoid some allocations
16:16
if u know length too u can with Vec::with_capacity
16:16
to avoid initial allocatiosn
16:16
i think vec grows 4->8->16
16:17
new doesnt allocate tho
Avatar
Thank
Avatar
just ate some pizza
Avatar
let mut nums: HashSet<*const i32> = HashSet::new();
16:17
what in the world
Avatar
why u using pointers
Avatar
isn’t it safe if it’s ref ptr
Avatar
It's safe, that's not the issue, it's not needed technically
Avatar
yea i dont see issue
16:18
but i am Mr. Idiomatic Rust
16:18
first, does ur code pass clippy cleanly
Avatar
2 . 2 . * . 2 . 2
Avatar
then does it pass clippy with pedantic
16:18
justatest
Avatar
croissant
Avatar
let br = Point(map[0].len().try_into().unwrap(), map.len().try_into().unwrap());
Avatar
This is the issue I was trying to fix, initially skimming through the problem I hadn't thought about numbers being the same nor the issue with 222 .*. ...
Avatar
what is the goal
Avatar
Avatar
Ryozuki
let br = Point(map[0].len().try_into().unwrap(), map.len().try_into().unwrap());
Do you enjoy it? 😄
Avatar
@Learath2 a bug i had was that i checked around the number after i encountered the current number finish
16:20
222.
16:20
i scanned also in the .
16:20
as if i was the number
16:20
so i moved a check to the next if its a .
Avatar
Avatar
Learath2
This is the issue I was trying to fix, initially skimming through the problem I hadn't thought about numbers being the same nor the issue with 222 .*. ...
this is me 90% of the time i go to do some leetcode
Avatar
@Learath2 btw i recommend u eagerly implement From and TryFrom for ur types
16:20
it makes code cleaner!
16:21
for example TryFrom<(usize, usize)> For Point
Avatar
Then I'd coded most of it, so I shoved some unsafe and Rc in there to patch it up
Avatar
then u do
Avatar
Avatar
Ryozuki
for example TryFrom<(usize, usize)> For Point
AHA, yes I knew there was a way to do that
16:21
I just forgor
16:21
i forgor
16:21
feeling like sleep or fortnite
Avatar
let a:Point = (map[0].len(), map.len())).try_into().unwrap()
Avatar
ChillerDragon BOT 2023-12-05 16:21:55Z
speaking about rust is only allowed on fridays!
Avatar
chiller do u have Fortnite
Avatar
ChillerDragon BOT 2023-12-05 16:22:10Z
nein
Avatar
ChillerDragon BOT 2023-12-05 16:22:24Z
woo
16:22
i only have minecraft and cs2
16:22
my solutions are here but
16:22
within commits
16:22
cuz i was lazy
16:22
to do folders
16:23
i dont have all too xd
16:23
oh i found a way to make it nice
16:24
i just put it in src/bin/day5.rs
Avatar
@Ryozuki any protips for l89? that one also looks nasty
16:30
For some reason type inference doesn't work there so couldn't do p.1.try_into().unwrap()
16:35
Another thing I miss when doing rust is the ability to just have a source file on it's own when I don't need any cargo
16:44
was cleaning more
16:45
@Learath2 clippy tells u about that line
16:46
if let Tile::Num(n) = &map[TryInto::<usize>::try_into(p.1).unwrap()] [TryInto::<usize>::try_into(p.0).unwrap()] { nums.insert(Rc::as_ptr(n)); }
Avatar
It only tells me to use an if let which sure
Avatar
but I was talking more about the nasty TryInto mess
16:47
all unwraps
16:47
add to main
16:47
-> Result<(), Box<dyn Error>>
16:47
so u can use ?
16:47
on any error
Avatar
That's a good idea
Avatar
do u want to panic on index error
Avatar
Yes, it should be impossible anyway
Avatar
btw why u do as_ptr
16:51
u can simply clone the rc
16:51
rc are meant to be cloned
16:51
they are a pointer itself
Avatar
Are two clones of an Rc pointing to one thing equal?
16:52
its the point of Rc
16:52
xd
Avatar
Are you sure?
Avatar
A single-threaded reference-counting pointer. 'Rc' stands for 'Reference Counted'.
16:53
its the definition of Rc
16:53
Rc, Arc, are pointers
16:53
smart ones
16:53
Box is a pointer too
Avatar
Two std::shared_ptrs to one thing won't compare equal
Avatar
unique ownership
16:53
who caress about c++
16:54
#[stable(feature = "rust1", since = "1.0.0")] trait RcEqIdent<T: ?Sized + PartialEq, A: Allocator> { fn eq(&self, other: &Rc<T, A>) -> bool; fn ne(&self, other: &Rc<T, A>) -> bool; } #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized + PartialEq, A: Allocator> RcEqIdent<T, A> for Rc<T, A> { #[inline] default fn eq(&self, other: &Rc<T, A>) -> bool { **self == **other } #[inline] default fn ne(&self, other: &Rc<T, A>) -> bool { **self != **other } }
Avatar
It's far from the point of an Rc is what I'm trying to say, std::shared_ptr implements the exact same thing yet won't behave the same
16:55
the partialeq of rc makes sense
16:55
what doesnt make sense is shared ptr
16:55
u want to check the contents equal
16:55
not the pointer itself
Avatar
I don't want to check if the contents are equal
16:55
I want to check if the Rcs point to the same exact object
16:55
u and ur weird stuff
Avatar
Each number should be accounted for once or you fail with 2 . 2 . * . 2 . 2
Avatar
i dont see how to remove the TryInto btw, since the index method is generic it isnt smart enough to know the into is usize
16:56
but the unwrap cleanup should make things clearer
Avatar
Avatar
Ryozuki
but the unwrap cleanup should make things clearer
Yeah with the ? it looks better
Avatar
Avatar
Learath2
Each number should be accounted for once or you fail with 2 . 2 . * . 2 . 2
yeah
Avatar
I use now helix since two weeks, love it
Avatar
Anyway, I'm sure yours looks better I just fixed what I had in hand quickly after I forgot about the edge case that there could be the same number around the symbol more than once
Avatar
Avatar
Learath2
Each number should be accounted for once or you fail with 2 . 2 . * . 2 . 2
ahh
16:58
i stored the coords
16:58
so i didnt have such problem
16:58
xd
Avatar
Avatar
Ryozuki
i stored the coords
Did you use the start of the number? I considered that aswell but then I'd have to rewrite my code to keep track of the start of numbers at each tile
Avatar
i only have part 2
Avatar
@Learath2 no, but i abuse the fact u only read numbers left to right
16:59
i store the current number as a string
16:59
i add it a temp buffer
16:59
let mut current_num = String::with_capacity(16);
16:59
let c = input[y][x]; if c.is_ascii_digit() { current_num.push(c); }
17:00
@Learath2 i think ur error is mixing coords with vectors/directions
17:00
me making the coords usize makes my code cleaner
17:00
btw usize has fn overflowing_sub(self, rhs: usize) -> (usize, bool)
17:01
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
17:01
anyway with the bound checks i do i ensure i dont overflow
Avatar
Given my lack of experience with HTML and JavaScript, I'm not certain if there are any potential exploits. The addr= attribute takes pretty much anything, not just IPs. Motivation was Discords unwillingness to bring back custom URI protocols as clickable links. Example: https://ddnet.org/connect-to/?addr=176.9.114.238:8340
Avatar
Avatar
Ryozuki
me making the coords usize makes my code cleaner
I could make coords usize, but then instead of just adding 8 vectors I need to make sure I don't underflow
17:09
idk, this entire thing ended up very nasty and I don't like how I have to keep 2 folders for part 1 and part 2 to keep rust-analyzer happy
17:14
Maybe I should learn rust properly so I can just not use autocomplete
17:15
Then I can just have a.rs and do a nice rustc --edition 2021 a.rs
Avatar
Avatar
Learath2
Two std::shared_ptrs to one thing won't compare equal
wat?
17:17
"Notes In all cases, it is the stored pointer (the one returned by get()) that is compared, rather than the managed pointer (the one passed to the deleter when use_count goes to zero). "
Avatar
Oh, that's cool
17:19
Though also annoying, are you supposed to memcmp if you want to actually compare two shared_ptrs?
Avatar
well or dereference it first
Avatar
I guess they made it ergonomic for the more used case
Avatar
btw Rc has ptr_eq
17:22
but again only a method without self
Avatar
I doubt I can make HashSet use the ptr as key anyway
17:22
Even if Rc has ptr_eq
Avatar
Avatar
Learath2
I doubt I can make HashSet use the ptr as key anyway
oh yeah
Avatar
Avatar
Learath2
Two std::shared_ptrs to one thing won't compare equal
mh thinking about it again, i wonder if c++ std would implement it like rust if they could break backward compability and use c++20's concepts/constraints 😄
Avatar
Avatar
Jupstar ✪
mh thinking about it again, i wonder if c++ std would implement it like rust if they could break backward compability and use c++20's concepts/constraints 😄
We don't really do the Deref thing in C++ at all though, it would be a massive paradigm shift
Avatar
i dunno if i like the rust behavior more, but it's probably more intuitive since u rarely cmp two Rcs
Avatar
Avatar
Learath2
We don't really do the Deref thing in C++ at all though, it would be a massive paradigm shift
there is a operator T()
17:36
which is basically deref I'd say
Avatar
I mean in Rust you can pretty much treat Rc<T> as T syntactically, which is why the comparison behaviour isn't too too unexpected
17:37
In C++ a level of indirection disappearing without you using a * is pretty much non existant
Avatar
i mean u do -> too on a shared_ptr
Avatar
But -> not .
Avatar
but you could overload it like that i think
17:38
it's simply not done bcs of the naming
17:38
shared_ptr not shared_ref
17:38
xd
Avatar
You could definitely, but it doesn't happen anywhere else in C++, it might feel wrong
Avatar
yeah
17:38
probably
17:38
i also dunno which one i like more tbh
Avatar
In Rust I think what they did does make sense, the rust way is pretending indirection just doesn't exist
17:40
It's also hard for me to think of what is best, I guess the most used being the most ergonomic is what is important
17:41
There are like 3-4 things that could be compared there, bit equality of the smart pointer objects themselves, whether the smart pointer objects are the same object, whether they point to the same object, whether their contents compare equal
Avatar
yeah xD
Avatar
Avatar
Learath2
If you don't fail on invalid input that's your mistake, not the function that does exactly what it says it'll do
yes, I'm just saying that this leads to people writing more bad parsing code
Avatar
Avatar
Ryozuki
but without ?
would sound like a weird choice
Avatar
Avatar
Learath2
Ah, that makes sense, I wonder what the rule is in that case to resolve the issue
the rule which method gets chosen? the one with the fewest dereferences (it's a little more complicated, check the rust quiz for edge cases)
Avatar
Avatar
Learath2
TryInto::<usize>::try_into(p.1).unwrap() this might be the ugliest thing I've ever written 😄
p.1.try_into().unwrap() didn't work?
Avatar
Avatar
heinrich5991
the rule which method gets chosen? the one with the fewest dereferences (it's a little more complicated, check the rust quiz for edge cases)
So if as_ptr() was a method instead, and we had an Rc<Vec<_>> and called .as_ptr() would it resolve to Rc::as_ptr()?
Avatar
Avatar
heinrich5991
p.1.try_into().unwrap() didn't work?
Nope since it was indexing a vec and somewhy couldn't infer it needs to be usize
Avatar
Avatar
Learath2
Another thing I miss when doing rust is the ability to just have a source file on it's own when I don't need any cargo
you can do that. rustc
Avatar
Avatar
heinrich5991
you can do that. rustc
Sadly all the tooling around rust assumes a Cargo.toml exists somewhere
17:58
So I need to give up autocomplete for that
Avatar
Avatar
Learath2
I want to check if the Rcs point to the same exact object
compare the pointers then
Avatar
Avatar
heinrich5991
compare the pointers then
Exactly what I ended up doing 😄
Avatar
Avatar
Learath2
So if as_ptr() was a method instead, and we had an Rc<Vec<_>> and called .as_ptr() would it resolve to Rc::as_ptr()?
yes
Avatar
Avatar
Learath2
Nope since it was indexing a vec and somewhy couldn't infer it needs to be usize
ah yeah
Avatar
Avatar
Learath2
Sadly all the tooling around rust assumes a Cargo.toml exists somewhere
ah
Avatar
Setting a vote timeout longer than 60 seconds with sv_vote_time caused the vote network messages to be discarded with the error message weird message 'Sv_VoteSet' (15), failed on 'm_Timeout' by the client, as the protocol did not allow longer vote timeouts. This adds no backwards compatibility for old clients. Old clients will not be able to see votes which are started with a timeout longer than 60 seconds. Closes #7583.

Checklist

  • [X] Tested the change ingame
  • [ ] Provi...
Avatar
This adds no backwards compatibility for old clients
18:54
justatest
19:05
lets accept it
Avatar
The voteset message should be redesigned to be honest. It should specify the tick when the vote ends and not the seconds remaining
Avatar
makes sense
Avatar
So should I just limit sv_vote_time to 60 again? That doesn't really solve murpi's issue for now I guess.
Avatar
Avatar
Robyt3
So should I just limit sv_vote_time to 60 again? That doesn't really solve murpi's issue for now I guess.
the issue was that votes don't appear. that's fixed by setting sv_vote_time's maximum to 60
19:16
for both old and new clients
19:16
also removing that limit in the client sounds nice for the future
Avatar
Based on @furo321's work (#7340). I attempted to fix the bugs in this PR, the big thing is that now we can scroll line by line no matter if the console entry is multiline or not. For that, I had to basically add the ability to use a LineSpacing parameter to render the text in order to keep things consistent for 1 line entries and multiline entries. I've tested it on multiple different resolutions and it seems to work quite well. https://github.com/ddnet/ddnet/assets/13364635/4a77901f...
wtf 1
19:24
4ad0a48 Add missing unpacker error checks for server and client packets - Robyt3 801274a Merge pull request #7580 from Robyt3/Message-Unpack-Check - heinrich5991
Avatar
b738f5f Fix votes with timeout over 60 seconds not being shown in client - Robyt3 f52aa8a Merge pull request #7592 from Robyt3/Protocol-VoteTime-Fix - heinrich5991
Exported 1,110 message(s)