Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



its been a while since i did any objc/swift but iirc you have to put UI updates on the main thread

so probably the macos implementation of SDL only does that when poll for events??

total guess tho

also yea i put a black square there first now to clear out the surface buffer before the loop:
code:
    Uint32 black = SDL_MapRGB(surface->format, 0, 0, 0);
    SDL_FillRect(surface, NULL, black); // NULL rect is entire surface
    SDL_UpdateWindowSurface((SDL_Window *)window);
i removed the delay too because the code itself is delay enough


thx all :)

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



hmm no i set a breakpoint & stepped through it. looks like everything is on thread 1 so idk :shrug:

anyway it works

Carthag Tuek fucked around with this message at 09:13 on Mar 21, 2020

gonadic io
Feb 16, 2011

>>=
need a bit of design rubberducking.

dominions 5 is an async game where players submit their turns whenever and then once all players have (or the usually 24 hour timer ticks over) then the server generates the next state and everybody submits their next turn.

i wrote a discord bot that checks the server state on a loop and then 1) allows players to query the state, and 2) sends PMs to players when a game they're in rolls over.

currently the design is: there's a shared mutex containing a hashmap for all servers to their state. one thread updates this in a loop, and then when players query the bot in the other thread they query the saved state so they they're not querying the server each time.

the main thing i struggle with is notifying the players. currently the update thread just does this if it notices that the server has advanced. this is less than ideal for a few reasons: 1) it prevents updates from happening while sending like 10 PMs, 2) if any of those calls fail it's handled poorly, 3) sometimes the game server decides to capture tcp connections forever which prevents all games from updating and requires a manual restart despite my efforts to put timeouts into my tcp calls, 4) duplicate pings are also happening for ??? reasons 5) the updates happen one at a time so when the bot starts you might have to wait for 20 other calls before your game has info

like what should this design look like? the update thread actually spawning child threads 1 per server it needs to look at? some kind of queue of notifications to go out so that the update thread(s) don't care about actually sending the PMs? rust specific but should i just stick with thread::spawn or start messing with futures? serenity (the discord library i'm using) doesn't support async but i can just run it in a threaded executor's spawn_blocking if i needed.

the original idea was to be super simple and it's just kind of grown organically and now things are starting to interact poorly

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

gonadic io posted:

need a bit of design rubberducking.

dominions 5 is an async game where players submit their turns whenever and then once all players have (or the usually 24 hour timer ticks over) then the server generates the next state and everybody submits their next turn.

i wrote a discord bot that checks the server state on a loop and then 1) allows players to query the state, and 2) sends PMs to players when a game they're in rolls over.

currently the design is: there's a shared mutex containing a hashmap for all servers to their state. one thread updates this in a loop, and then when players query the bot in the other thread they query the saved state so they they're not querying the server each time.

the main thing i struggle with is notifying the players. currently the update thread just does this if it notices that the server has advanced. this is less than ideal for a few reasons: 1) it prevents updates from happening while sending like 10 PMs, 2) if any of those calls fail it's handled poorly, 3) sometimes the game server decides to capture tcp connections forever which prevents all games from updating and requires a manual restart despite my efforts to put timeouts into my tcp calls, 4) duplicate pings are also happening for ??? reasons 5) the updates happen one at a time so when the bot starts you might have to wait for 20 other calls before your game has info

like what should this design look like? the update thread actually spawning child threads 1 per server it needs to look at? some kind of queue of notifications to go out so that the update thread(s) don't care about actually sending the PMs? rust specific but should i just stick with thread::spawn or start messing with futures? serenity (the discord library i'm using) doesn't support async but i can just run it in a threaded executor's spawn_blocking if i needed.

the original idea was to be super simple and it's just kind of grown organically and now things are starting to interact poorly

Ideally you'd have some lightweight tasks/futures library backed by a thread pool. Then the update thread manages the tasks lifecycles.

The C# thread pool has a separate set of UI threads; I'd check the docs to see if rust's is similar.

So yes; futures.

Aramoro
Jun 1, 2012




I think id probably use a timer lib like Quartz and generate a cron style job per server its checking. That job can then spawn a thread to check the server state and send the messages to a queue to be sent out.

toiletbrush
May 17, 2010
I don't know much about C++ and avoided learning it at every opportunity, but this vid was still quite interesting...
https://www.youtube.com/watch?v=j0_u26Vpb4w

redleader
Aug 18, 2005

Engage according to operational parameters
serverless

redleader
Aug 18, 2005

Engage according to operational parameters
kafka

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Aramoro posted:

I think id probably use a timer lib like Quartz and generate a cron style job per server its checking. That job can then spawn a thread to check the server state and send the messages to a queue to be sent out.

quartz is a really good rec for this type of thing :yeah:

MrMoo
Sep 14, 2000

ctps: wayfinding, started a new project.log. I have no idea what I'm doing and I hate all GIS software and developers already.

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
GIS is a huge field. I agree though, like all software, it is absolutely terrible.

You are in the lucky position to choose your flavour of terrible though. If you go into more academic software the UI gets more insane. And you risk pulling in the ocean of terrible tools that is related to mapping. Like, GMT is extremely widely used and extremely powerful, but holy gently caress is it bad. It beats ffmpeg in terms of insane options. It is more convoluted than the openssl CLI. And as you go into more commercial sections you'll run into people who will want everyone interacting with your tool to use a USB dongle. Yes, even for web poo poo.

Corla Plankun
May 8, 2007

improve the lives of everyone
if the terminals are stationary it seems like a waste to use gis

Spime Wrangler
Feb 23, 2003

Because we can.

Using standard GIS tools (meaning the desktop Qgis/GRASS/ArcGIS software) is probably not the way to go for custom interactive stuff. You probably want to ask yourself if GIS-based tools [edit: anything that uses a global spatial reference system, not just the desktop GUI software] even make sense if what you're doing is all at the building scale and mostly on the interior. It may make sense if you want to easily integrate with existing survey data, off-the-shelf mapping tools, or expect some deployments to cover a large area.

Last time I built a web frontend for custom GIS stuff (years ago when I was basically a self-employed junior dev so grain of salt) I used:
- PostGIS/postgres for the database/geoprocessing
- Django with GeoDjango for the webserver layer
- Leaflet for frontend mapping
- D3 for custom interactive elements

PostGIS is a great tool for doing annoying computational geometry stuff like making buffers, doing spatial queries, and storing/converting georeferenced data.

You'll want to bone up on basic GIS concepts like spatial reference systems, each of which has an SRID you can specify when pushing/pulling data from postgis. Every major jurisdiction is going to have a set of their own reference systems (usually at the state level) denominated in some linear unit from a reference point (e.g. feet). There's a bunch and they're all localized because what they're trying to do is map a euclidean grid to a segment of an oblate spheroid, so once you start moving from the origin point the error (difference between reference coordinates and real coordinates) starts to build up.

The global reference systems (usually WGS84 or NAD83 datums) use coordinates in lat/lon and account for the measured shape of the earth, but you'll want to do your computations on a flat plane if possible. If you're deploying in multiple states or even different cities that may affect how you do your processing. You absolutely 100% want to use something like PostGIS for these operations if you're moving between e.g. google maps WGS84 lat/long coordinates (SRID 4326) and the building's survey data in e.g. EPSG:2260 - New York East coordinates (SRID 2260), which are in feet and referenced to the NAD83 datum.

This is all different from projections, which is how the map gets displayed (e.g. mercator, lambert, etc), but which probably won't make a big difference at the scales you're working at. You'll have to choose one though, and make sure if you're doing overlays with different tools (like D3) that they're using the same projections.

Note I am probably using some terminology wrong, but my last GIS class was in like 2009.

The other option is just defining your own coordinate systems based on the Revit models or whatever BIM tool you're pulling your data from and ignoring the GIS stuff entirely. You'll lose access to some cool off-the-shelf algorithms but that may or may not matter for what you're doing.

Spime Wrangler fucked around with this message at 17:31 on Mar 24, 2020

MrMoo
Sep 14, 2000

My targets are 1: University of Texas, Houston, however starting with only one building, not the entire campus, 2: The NBA offices in NYC, and 3: Dallas Fort Worth Airport. These are all at the level of not having to care about outdoors and mapping services, but it's 2020 and you expect some maturity in products.

One angle would be TinyOWS with Postgres/Postgis, and either OpenLayers or Leaflet.

Just looking at something simple that would not be painful to grow in the future. There are 2D things like d3 floorplan but 3D is a desired goal, at least for extruding rooms from a floor plan.

I want a mechanism to define waypoints on a map, to start building up a graph for path routing. It's probably quite simple but this domain makes it look complicated.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

ecommerce partner is complaining that our message queue is 'hammering' their api and i should slow it down

he sent me a log excerpt with the comment 'look at all the calls it made just in the last minute!'. 38 requests/min, truly a DDOS-grade attack

redleader
Aug 18, 2005

Engage according to operational parameters
as i'm sure you're well aware, all ecommerce systems, and everything adjacent, are pure, molten garbage

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

redleader posted:

as i'm sure you're well aware, all ecommerce systems, and everything adjacent, are pure, molten garbage

yeah but im pretty sure in this case they just never learned to grep their own logs and they were frantically wearing out their scroll wheels

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


I told an offshore dev to actually write some comments and format the code so it's not just one mega worker.cs file that jumps around calling itself so they've just started putting \\\ summary blocks on every statement and now have two class files that jump around calling themselves with no discernible pattern :negative:

this service just polls for updates, gets a list of records to update and runs through them, so you'd expect an out worker to call a method to build a list of wrapper objects around each update then loop over each item in it, calling a process method on it. instead it's a wild ride of lists intancing objects that then get added to more lists that pass to methods that return bools that modify the original state of the object and pass it to other methods

Chalks
Sep 30, 2009

to save money we shut down our azure development environment overnight.

this morning it failed to boot up because azure has run out of capacity in the entire north europe region.

loving owned.

Aramoro
Jun 1, 2012




Chalks posted:

to save money we shut down our azure development environment overnight.

this morning it failed to boot up because azure has run out of capacity in the entire north europe region.

loving owned.

lol that loving owns.

Gonna suggest to our DevOps they turn off Azure at night now.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Chalks posted:

to save money we shut down our azure development environment overnight.

this morning it failed to boot up because azure has run out of capacity in the entire north europe region.

loving owned.

hahaha :rip:

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


oh cool they've never actually debugged or run the service they wrote because as soon as you start it it blows up with missing config errors, that's a good start!

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
woops I forgot to shut down the dev cluster last night

CPColin
Sep 9, 2003

Big ol' smile.
About two hours after breakfast, I'm gonna flush the dev cluster.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Holy poo poo I said "this needs to be refactored so it's not just one mega worker class, it should have separate classes" and what has he done?

he's c&p'd the worker.cs content into two separate files under a new class then just.... Made the base worker inherit the new file

what in the gently caress

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Chalks posted:

to save money we shut down our azure development environment overnight.

this morning it failed to boot up because azure has run out of capacity in the entire north europe region.

loving owned.

i remember looking into this when i first experimentally set up a couple VMs on the monthly msdn free credit

at the time azure offered an option to shut down vms at a certain time every day, but it didn't have the corresponding option to also turn them back on, you had to write a cronjob with the azure shell yourself

i remember wondering why the gently caress they would offer such a literally half-assed feature

now i guess i have an idea :aaa:

Aramoro
Jun 1, 2012




Powerful Two-Hander posted:

Holy poo poo I said "this needs to be refactored so it's not just one mega worker class, it should have separate classes" and what has he done?

he's c&p'd the worker.cs content into two separate files under a new class then just.... Made the base worker inherit the new file

what in the gently caress

Sounds like a failure in the specification of the task there. He's done exactly what you asked like like a spiteful Code Djinn.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Aramoro posted:

Sounds like a failure in the specification of the task there. He's done exactly what you asked like like a spiteful Code Djinn.

this code is like the platonic ideal of bad. there are functions called LoadFoo that call procedures called getFoo that read or write data depending on what you called them with. zero comments on methods but random summary blocks dotted around on try{} statements

it's impossible to follow

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
class count sounds like the least of your problems. in general pointing out typically-used indicators of "bad" code isn't much of a diagnosis. what's the actual problem with the code?

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

Powerful Two-Hander posted:

Holy poo poo I said "this needs to be refactored so it's not just one mega worker class, it should have separate classes" and what has he done?

he's c&p'd the worker.cs content into two separate files under a new class then just.... Made the base worker inherit the new file

what in the gently caress

lol

i love stories like this because it makes me appreciate how minor the dumb disagreements i have at work are with generally competent coders

Bloody
Mar 3, 2013

sounds like you're getting exactly what's being paid for

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


pokeyman posted:

class count sounds like the least of your problems. in general pointing out typically-used indicators of "bad" code isn't much of a diagnosis. what's the actual problem with the code?

Well, it didn't actually run so there's that, once the immediate issues were fixed (bad references, missing config etc.), it's clearly been written as "I am going to read the design spec and write one big long procedural list of statements" which is OK ish as a start point, but this has been worked on for a month now and the output at that stage should be possible to follow for someone else

"oh but it works" is not good enough, it needs to be maintainable and a 400 line class called "database access" that handles update polling, sending emails and reading/writing mixed records and has random internal class properties that are written to and from on each operation to use as temp storage is not maintainable

edit: and who writes a stored proc that takes a bool to decide whether it will return a list of records or write an update to one records :barf:

Edit 2: the service doesn't actually manage its run process properly, if it runs out of things to do it just quietly dies instead of sleeping and checking for updates later

Powerful Two-Hander fucked around with this message at 16:52 on Mar 25, 2020

NecroBob
Jul 29, 2003
can someone please tell me why the gently caress
code:
!null
evaluates to true in javascript.

why is that a thing. :psyduck:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



thats p common

C code:
#include <stdio.h> 

int main() {
    if (!NULL) {
          printf("lol\n");
    }
}
Python code:
if not None:
    print("lol")

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



also in obj oriented languages its usually used to check if a variable points to an object or not

Chalks
Sep 30, 2009

NecroBob posted:

can someone please tell me why the gently caress
code:
!null
evaluates to true in javascript.

why is that a thing. :psyduck:

if(!email) {
alert("set an email address you dumbdumb");
}

null evaluating to false is pretty useful

NecroBob
Jul 29, 2003
okay, that makes more sense

EDIT: I work in C#, so assigning null to something that could be evaluated as a boolean type seems wrong. Additionally,
code:
bool dicks = null;
causes VS to take a big squiggly red poo poo on that line. I feel less bad about my initial revulsion and more aware why !null is a thing. Still feels a little weird.

NecroBob fucked around with this message at 17:32 on Mar 25, 2020

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


why is there a static mail sender method sitting in the program wrapper around the service is adding a new class file so hard?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Powerful Two-Hander posted:

why is there a static mail sender method sitting in the program wrapper around the service is adding a new class file so hard?

easier to ctrl-f in a single file :shepface:

Adbot
ADBOT LOVES YOU

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Krankenstyle posted:

easier to ctrl-f in a single file :shepface:

this sounds like something from a "javascript best practices guide"

honestly the layout of this is one big anti pattern. like how do you get the current object state before updating? Oh obviously you call a method named "sendupdatemail" and it will either throw an error, end an email or update a class property

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply