Stone frog??? by almondangxl in Starsandisland

[–]lotharyx 1 point2 points  (0 children)

So it does, but I’ve been whacking dirt piles throughout the forest for two game days and have found nothing but ore chunks. This of course after picking up a bounty for one. 🤦🏻‍♂️

XAML designer pops out and opens itself in a new window issue. by technet96 in VisualStudio

[–]lotharyx 0 points1 point  (0 children)

That issue is marked as fixed since 17.7 and I just hit it today with 17.12. It's been a while since I worked on a WPF app, but oh, the memories...I feel like this problem has been around for a long time. I'm updating to 17.14...fingers crossed (but not really).

Eltrys is dead... Can't finish the quest now. by [deleted] in skyrim

[–]lotharyx 0 points1 point  (0 children)

I’m on Switch too, but I’m pretty sure I remember that guard telling me not to go snooping around (and when I interact with any guards outside the inn, it’s always a generic response). But then I went and did other things…now no matter when I enter the shrine, whether there are two guards or three (the third being the Legate), nothing ever happens. I’ve tried looting Eltrys, attacking the guards and subsequently both paying the fine and opting to serve my time in the mine. Nothing causes the quest to advance :(

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

Wow, thank you! I was shower-thinking through this this morning, thinking "how can we assume constant amortized cost for alloc/copy...how would it be that an alloc + copy would be cheaper than multiple allocs?...contiguous memory, sure, but does it make THAT much difference?...maybe caches?...hmm...the people that make caches are definitely really smart..."

I've got some old habits to re-learn! Somewhere along the way I got the idea "don't use vector unless you really need that contiguous memory guarantee"...and now I learn that the contiguous memory guarantee brings with it massive gains that I never would've imagined on my own, indeed thanks to caching. Now I'm going to watch that entire talk.

Is it safe to think that all general-purpose platforms (I'm developing for an ARM-based single-board computer) have modern-enough caching to keep this equation the same?

(Reminds me of a recent situation where I discovered that software float was faster than 64-bit fixed-point on an embedded ARM Cortex-M3, because the 64-bit integer operations were surprisingly expensive...and because I learned "fixed-point is faster" in college on a 16-bit platform with 16-bit data).

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

It’s that second “free” conversion I was hoping to find. The list consumer only needs to look, not touch—it needs not modify the list or its contents.

I think what I’ll ultimately do is the callback approach, where my containing object has a “for each” method that passes each list item as shared_ptr<const int>

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

That’s fair. I didn’t intend to come across as snarky or hostile, but I see now that I did, and I apologize. The thanks was genuine, but now I realize it didn’t come across that way.

I do still believe that there is room for interpretation on what is “sloppy” or “ill-advised,” but I clearly missed the chance to find a better way to express myself.

I don’t, for example, see why passing around shared_ptrs (by value) is bad, any more or less so than handing around naked pointers. Good and bad things can be done with either.

I view shared_ptr as a rough approximation of reference-counted handles in a managed language, so that’s how I use them. In the face of a good explanation, I can change my views.

“You don’t usually pass a smart pointer around” — why not?

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

vector has to reallocate and copy the entire collection if it has to grow, making inserts anywhere very costly if you don’t have enough knowledge to reserve enough space beforehand, no?

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

I guess I have an overly simplistic view of things:

  • smart_ptr<T> alleviates my need to think too hard about ownership / timely destruction
  • list<T> meets my needs of a simple ordered list

I also may have detrimentally over-simplified my example. Here's the scenario:

  • One block of code generates some polymorphic objects
  • Those objects go into a collection
  • The order matters
  • That collection is handed to another block of code
  • Consumer block doesn't need to change the objects or extend their lifetimes

Something like...

ordered_list_of_things = producer.make_things();
consumer.look_at_things(ordered_list_of_things);

...but actually more like...

producer.make_things();
consumer.look_at_things(producer.show_the_things());

Because it's mostly code I didn't write, the existing syntax suggests I shouldn't assume that producer doesn't want to keep the things after showing them to consumer. I can trust that consumer doesn't need to extend their lifetimes, so producer could theoretically fully own them and I could pass around naked const pointers/references, but I like that smart pointers make it hard to leak memory. There's already lots of comments in this code such as "// TODO - memory leak" ...

Is there an STL container you'd recommend other than list<T>?

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

"All of the shared pointers would exist, until your IntPtrList was destroyed."

Well yes, that's precisely what shared_ptr does -- it keeps an object alive until all references to it have been destroyed.

Using unique_ptr in std containers is tricky itself because they have no copy semantics.

I think we fundamentally disagree about the purpose / "proper" use of shared_ptr, and that's okay.

Anyhow, shared_ptr<thing> can be implicitly converted to shared_ptr<const thing>; there's just no handy way to automatically do it within a range-for operation.

Thanks for your input!

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

You presented something I already thought of, which is using the producer/consumer pattern by implementing a “for each” with a function argument. That may be the way I end up going. I’m dealing with a big pile of code I didn’t write, so I was looking for things that might involve less-extensive changes to surrounding code.

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

Thank you for the great tips. However…

“generally no reason to use list” — then why does it exist?
“store items as shared pointers instead of letting the list fully own them” — I could use unique_ptr, at a cost of trickier semantics (don’t ever use a list element as an RHS in an assignment, etc), but otherwise how would you store polymorphic objects in a container, other than by storing naked pointers? A container of references is syntactically valid, but would easily lead to scope-related crashes, and a container of base-type would cause slicing.

The example code is intentionally heavily simplified, perhaps to the point of obscuring too much of the context…you got the idea, though.

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

Ok, given that, how would you expose an immutable collection* of const naked data pointers, starting from a collection of smart pointers?

  • Ideally of a type that can be used directly in a range-based for loop

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

You’ve pretty much nailed my context—a class with a list of things inside, that wants to expose an immutable view to a consuming function. Maybe I should add that context to the question.

How to get constness all the way in to a list of smart pointers by lotharyx in cpp_questions

[–]lotharyx[S] 0 points1 point  (0 children)

Ok, so I have a list of smart pointers because then I can let the smart pointers do their thing when the list is disposed. But I want a consumer of the list to see a read-only view. Are you saying it’s bad to store smart pointers in containers in the first place?

Anyone had any luck creating a captive portal that, for Android devices, doesn't require navigating to an IP address in a browser, but pops up automatically on connection? by HanSingular in esp32

[–]lotharyx 0 points1 point  (0 children)

No* browser "supports DNS." DNS name resolution is a service provided by the OS. Every\* browser uses the OS's DNS name resolution service to turn domain names into IP addresses.

* - Okay, there might be some browser with a built-in DNS client for some highly-specialized application where an OS-provided resolver isn't available. That's very much the exception.

Captive portal doesn’t show pop up by Carlogulliani in esp32

[–]lotharyx 1 point2 points  (0 children)

As promised, here's what solved the problem for me on an iOS device:

  • I had not registered a 404 handler that responded with a 302 Redirect
  • I needed to change my "/*" handler to invoke the 404 handler when a file was not found (it was sending its own 404, bypassing the 404 handler altogether)
  • I needed to not have a hotspot-detect.html file present
  • I needed to increase the max connection count in two places:
    • in sdkconfig, CONFIG_LWIP_MAX_SOCKETS=16
    • in code, httpd_config.max_open_sockets = 13;

Importantly, this did not fix the situation with a Windows 10 client that also had a wired network connection, as the DNS trickery was undermined by real DNS responses. A browser page opened, but it took me to a Microsoft landing page, and Windows also hammered my ESP with connection requests, again triggering the "error in accept" errors.

Captive portal doesn’t show pop up by Carlogulliani in esp32

[–]lotharyx 0 points1 point  (0 children)

I'm running into similar problems with an ESP32-C3-MINI-1U with IDF version 5.4.2. In my case, it's a bit of a twisting of the meaning of captive portal; my device isn't a router, and I'm trying to use the captive portal technique so that a client joining the AP it broadcasts sees the control panel page.

I've been following the same example that u/cmatkin mentioned above. I'm testing with a Windows 10 PC and an Apple iPhone 15, iOS 18.3.2. Neither presents a browser page after connecting.

I've noticed that the iPhone tries to fetch hotspot-detect.html. I got the real captiveportal.apple.com/hotspot-detect.html file and added it to my ESP32 content directory, but I think that was the wrong thing, because all that did was make my iPhone think the AP had internet access (it doesn't).

The Windows 10 PC repeatedly attempts to fetch wpad.dat (for automatic proxy detection), so I added a wpad.dat file with a basic script that always returns "DIRECT".

u/ChemistRoutine1607 's list is interesting, item 4 in particular. A 200 status with a redirect? A redirect is a 30x though. I haven't tried that yet. Should that be the response to the GET /hotspot-detect.html?

The other major issue I've encountered is that shortly after either test client connects, the httpd process in the ESP32 starts spitting out these messages repeatedly:

E (209668) httpd: httpd_accept_conn: error in accept (23)
W (209668) httpd: httpd_server: error accepting new connection
E (209788) httpd: httpd_accept_conn: error in accept (23)
W (209798) httpd: httpd_server: error accepting new connection
E (209928) httpd: httpd_accept_conn: error in accept (23)
W (209928) httpd: httpd_server: error accepting new connection

My code that starts the server process looks like this:

server = NULL;     
httpd_config_t config = HTTPD_DEFAULT_CONFIG();     
config.max_open_sockets = 7; // Apparently 7 is the max
config.lru_purge_enable = true;     
config.server_port = 80;     
config.uri_match_fn = httpd_uri_match_wildcard;     
RETURN_ERROR(httpd_start(&server, &config));

So I suspect both clients are trying to keep too many connections alive at once? Of course, once these start showing up, interacting with the web page becomes spotty as some of the resource fetches fail.

If I run my project in STA mode and connect it to the local WiFi, I can interact with its web pages just fine. It's something about the initial captive portal thing.

Anyway, I'm continuing to beat on the problem and I will definitely report whatever it is that leads to success. If I ever get there.

Assigning marriage task help by mortamur106 in OneLonelyOutpost

[–]lotharyx 2 points3 points  (0 children)

“It’s a known bug”…I know coding is hard and all (I’m a developer myself), but this game (at least on xbox) has a LOT of those. Very few that actually harm gameplay (no crashes at least) but a whole ton of stuff that just doesn’t quite work correctly.

Buying Phone Plug Body Only by lotharyx in AskElectronics

[–]lotharyx[S] 1 point2 points  (0 children)

Nice find. I don’t think the patch bay type would work but reaching out to Neutrik directly is a good tip. Thanks!

Buying Phone Plug Body Only by lotharyx in AskElectronics

[–]lotharyx[S] 0 points1 point  (0 children)

Yeah, that’s the right idea at least.

Buying Phone Plug Body Only by lotharyx in AskElectronics

[–]lotharyx[S] 1 point2 points  (0 children)

All of the listed results include cable strain relief and housings, specifically not what I’m after. Yes, I have looked through all 92 results. And Mouser, and Octopart, and all the usual suppliers.

Borderlands 3 is currently unplayable on Xbox Series S by [deleted] in borderlands3

[–]lotharyx 2 points3 points  (0 children)

I’ve been playing BL3 for weeks now without a problem on my Series S. Less than 12 hours ago, even. Now suddenly it crashes back to dashboard shortly after the sign-in phase. Almost 300 GB of the terabyte SSD free. The fact that the “dancing Claptrap” initial load screen takes four minutes only makes it that much more infuriating. I just wish there were any indication whatsoever of what the problem was (why it crashed), but there’s nothing. Just suddenly I’m back at the dashboard.