Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

777 Good

About SyncViews

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I think the default allocators are a lot better than they were, you probably can't write a general purpose allocator that is outright better now. I believe for example MSVC ends up in HeapAlloc which by default is the Low Fragmentation Heap which uses "predetermined buckets" (and I am guessing a free list for each) to deal with anything less than I believe 16KB (with I believe 4KB virtual memory pages). But you can beat it easily for a specific use case, sometimes while also optimising memory layout to make better use of a CPU cache (iterating compact arrays good, jumping around the heap with a linked list or array of pointers less so). As mentioned allocators for a specific size can be really simple and faster. This works well with common objects, but maybe not so well as an "Entity allocator" when the different entity subtypes might all have drastically different sizes, quantities, life cycles, etc. If you can store something directly in an array, that is often about as near optimal as you can get, as iterating through it will make good use of the CPU cache and reduce cache-misses over iterating through pointers, even if all those pointers came from the same memory block, jumping back and forth is less optimal. You might mark array elements as "dead" in some way, skip it when iterating and allocate new objects into the first/next dead element. You might compact the array so it only contains valid elements, and always place new objects at the end. this compacting step makes the use of shared_ptr/weak_ptr impossible, as the object will change address. Another one I have seen, is to allocate a large pool, and then use that as a stack for a single operation, say an update. Allocations simply take the top of the stack, and deallocations are no-op. At the end of the operation the entire pool is considered empty. I have seen this more commonly in various C programs to avoid a lot of manual tracking for free(ptr) when dealing with say temporary strings, arrays, buffers, etc. Assuming you have a rule that a raw pointer is never stored like in my example code before, then yes, roughly. But I always just made my unique ID "handle" part of the object itself. As for the "table", well usually my scene/map needs to have track of everything anyway to process updates, etc. So I already have that, no separate table. e.g. class Entity { public: Entity(unsigned id) : _id(id) {} unsigned id()const { return _id; } private: const unsigned _id; };
  2. E.g. something a player does causes the object to delete itself. Why does everyone think it has something to do with threading? Because of how you wrote "no way to check if the returned pointer is valid" and "could be deleted at any point". In a single threaded environment, "deleted at any point", should not be true, and you should be able to guarantee a returned pointer is safe. Entity *target = map->get_nearest_enemy(this->faction(), this->position()); // target should be valid, and there should be no way for it to become unexpected invalid, within this code block if (target->type()->valid_assassination_target()) { target->kill(); // Now, maybe the pointer is invalid } The "something a player does causes the object to delete itself" can't happen in the middle of that block if it is only single threaded, and so the raw pointer can be used safely, keeping it over a longer duration of course has other considerations. The advantage of using a unique ID / "handle" there, is because of memory reuse you can't safely validator a pointer at a later time. But being able to store an ID between frames you can, and then you can retrieve it again later safely. Entity *target = map->get_entity_by_id(target_id) if (target != nullptr) { // target still valid, raw pointer is safe as before } else { // target is gone target_id = INVALID_ENTITY_ID; // fairly easy to have some sentinel value that acts like a null pointer } In a more complex environment, you could turn that into your own custom smart pointer, I did that previous as an optimisation on "get_entity_by_id" in a design where I stored things in std::vector like arrays and compacted them (meaning objects could move memory address to keep an efficient memory layout, although that was part of an ECS design, so "Entity*" like OOP didn't exist at all)
  3. My personal preference, be it C, C++, Java, .NET, whatever, is to have functions either return unique ownership (normally a new object, which is then the sole responsibility of the caller), or to return a reference/pointer to something the API still owns and manages. In C++ `unique_ptr` and raw pointers fulfil that nicely. For function parameters, the same deal where possible, the API either takes ownership, or just uses the reference for a fixed duration, normally the function call itself. Sounds more like a `create`. I think the problem here is the "deleted at any point". What is able to delete it, why is it? Are you multi-threading the game logic? You definitely don't want an API design where a pointer/reference/etc. gets invalidated by some other thread, maybe before a create/get function even returns. A solution I used with a couple of things was to say my object references must stay valid during a particular update frame (I was essentially storing them in std::vector). This meant any pointer within an update was guaranteed safe, but I had to use unique ID's to track specific things between frames. I think it is important though, even if you do use "shared_ptr" or "handle", or even in languages like Java and .NET, to try and stick to a single ownership model for object lifetime where possible, as it is easier to think through, and even garbage collector languages have things it does poorly (Close/Dispose/etc.) or the possibility of memory leaks (e.g. forgetting to remove things from collections). e.g. in this case you object is probably still "owned" by the scene, and once removed it is marked "dead", removed from the scene collections, any getter fr it returns null, it's not rendered, no physics, no updates, etc. and any remaining references are mostly just a safe way for other objects to see it "is dead" in a safe way. `unique_ptr` has literally zero cost, `shared_ptr` you probably want `enable_shared_from_this` (or traditional intrusive ref counting). You probably regardless want to avoid using heap dynamic allocations for objects. The fastest is generally going to be a vector<T> of values, due to continuous memory, but sometimes that is not practical.
  4. Not sure about the Direct Manipulation API, which bit/interfaces were you looking at specifically? I was under the understanding it was built on the window events, but maybe I understood it wrong. I am surprised raw input didn't report anything, which exactly did you register for? I am sure I recall some stuff specifically about contact points / touch pads. There is also WM_TOUCH, do you get any messages for that?
  5. Well, like I said, not got any complete game examples. There might be an article out there, but generally MMORPG, Battle Arena, or more conventional FPS/RTS/etc. that host centralised servers I expect will have these things purely internally and not show much to the outside world. If you look at say Valve's offerings, the dedicated servers available to players are far less featured than the overall system that powers say CS:GO and Dota2 (e.g. all the ranking stuff, player reporting, support tickets, etc.,). As far as general control interfaces go, well basically any piece of modern network gear has a web portal. You probably used one on say your router. A lot of IP Phones (common in offices so they can just have a single ethernet network) also have such an interface, as well as firewalls, email gateways, switches, etc. And the majority of web related server software you install these days will as well, such as forums, bug trackers, .etc. For managing support tickets, both technical ones / bug tracking, and just general customer support there are various off the shelf services that can be used. For Warframe uses zendesk (https://digitalextremes.zendesk.com/hc/en-us), which you thus could get and take a look through from an admins perspective. I am sure some games also use fully "rebranded" ones, or at least their own customer facing user interface, while others simply use a forum for such things. A lot of these user based platforms also have the ability to integrate with external software/databases for the purpose of user profiles and logins, commonly called SSO single sign-on (so I can use my single user account/password, to log into say the game, the forums, and the support desk), so you could see how some of them are doing that (e.g. quick search found https://support.zendesk.com/hc/en-us/articles/203663826-SSO-single-sign-on-options-in-Zendesk see "enterprise single sign-on section"). For GUI consoles, on commons ones on Window's I can think of is the Server Manager, Group Policy, and SQL Server management tools, but I only used them from a basic developers perspective, I am not an admin.
  6. Do you link with any other libraries? The CRT version must match all static libs, and often must match all DLL's (exceptions are libraries that completely abstract malloc, free, etc.), and I think I have seen some similar things with a static library compiled with a different version or settings (debug/release static/dll/singlethreaded CRT).
  7. You still need to provide more information. And "1.5" GB is nothing for many large databases, they can be terabytes or more, all depends on purpose. 1.5GB with a single table and 40,000 rows is only about 40KB per row on average, which while maybe bigger than the average row, can really be many things. What exactly is the schema for each table (the SQL `CREATE TABLE ... ` to make them) Provide an example of data for each table, at least 1 row Explain how that data is being used
  8. I would assume these days, most of it is basically a website, although I have never seen or searched around for such information on MMO's specifically. A lot of data, especially to do with user accounts / profiles is probably stored in a regular SQL database, and a lot of modern server software has moved away from using Win32 API, MFC, WinForms, etc. often using custom communication protocols (assuming remote management was possible at all, other than Remote Desktop the server and use the GUI tool there) to web based management. I have seen even less terminal based management tools. While they may be very slightly easier to develop, console programs give up a lot of ease of use and presentational flexibility. Plus your average new hire for the support team will have no idea about consoles etc., but is likely familiar with how to use GUI programs / webpages.
  9. "only text data" isn't really a helpful description and text is not magically smaller than binary data, infact it can often be larger. What are you storing in your database? How do you need to query it? Can you delete some unneeded data?
  10. I found when debugging these things starting with the simplest possible object can help a lot, like a cube with known coordinates and uvs (e.g. exactly 2x2x2 and a basic "t" texture unwrap). At that point its a small enough thing to check everything manually. Does your mesh loading code have the expected vertices and indices? Are the indices in the expected order to get triangle strip front faces? Does the vertex shader transform each one as expected? Do the right ones get culled? etc. Maybe put 2 cubes in the mesh and make sure the restart is correct (either a -1 index, or some degenerate triangles).
  11. So what exactly are you doing? Is it to learn how programs worked in DOS and similar systems? Because that is nothing like modern Direct3D, OpenGL, etc. It is definitely worth knowing, but it is a different style as you had much more direct hardware access plus older features due to the use of 16bits and the need for more than 64KB of memory (essentially a non-problem for almost all 32bit software, and basically everything in 64bit allowing the use of a "flat" address space). Also like I said, C and assembler were common (both still useful skills). If you can't get an actual DOS machine to use, you can use an emulator to run such programs.
  12. SyncViews

    SO_REUSEADDR - when should this be used?

    If I recall the warning in Window's is potential unintended consequences, including security issues, when another program can SO_REUSEADDR on a port that you are still currently using. As far as I know on Windows for normal sockets, they get cleaned up, including listen sockets, along with the process. So if you close the process then restart it, you shouldn't need SO_REUSEADDR. Windows also has a SO_EXCLUSIVEADDRUSE and my understanding is that new software should use that for security reasons. https://docs.microsoft.com/en-us/windows/desktop/winsock/using-so-reuseaddr-and-so-exclusiveaddruse Although worrying about that sort of denial of service is probably not an issue for games, and seems to assume there is already malicious software on the system. I believe it also refers to hijacking existing UDP "connections", not just a TCP listen socket, but I never really investigated this.
  13. SyncViews

    Motion-planning for spaceships with physics

    Not sure on a nice math solution, planning courses in space in complex (even more so once you add gravity, which you havn't here). One quick solution I have used for vehicles in various contexts is to compute a "stopping distance" and use that in my vehicle AI update. This is slightly different to what you have in that it is not "planned", it would simply keep accelerating (in my case I had a velocity cap so not tried with such high speeds) until an update where "stopping_distance >= remaining_distance".33 Another hack approach, is to just have a guess of what the flight plan could be (lets say start on your accelerate half way, then flip and burn) then simulate it and see how far it ends up being off. Then add some more acceleration in that direction (change angle/thrust veector a bit if off left/right, flip and burn sooner/later if distance is off) to the flight plan to try and correct the error, until it has one that is good enough. Another work around would be to try and burn off any "wrong" velocity early in the path so that it is heading in exactly the right direction, although certainly a less optimal plan, and then you have a simpler flip and burn in a single dimension.
  14. SyncViews

    A star implementation

    If you have a graph for a 2D tile grid, you could store the nodes in a 2D grid. Then it is a nice simple O(1) to get the node for any given position.
  15. Chrome have some API's for local storage, but I do not believe they are standard. Although a Chrome feature, the MDN has the best docs I could easily find https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem#requestFileSystem MDN says the storage limit on Firefox is potentially 0, and up to 2GB max, which would require at least 20GB free space on the user profile drive due to how it allocates the maximum (on a per eTLD+1 basis, so game.gamedev.net and gamedev.net share a limit). https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria#Storage_limits I don't think there is a general way to guarantee such a massive amount, personally Id have thought having a downloadable version is the way to go, but I don't play or develop such web games so not sure what the common practice is there these days For all "normal" content I would highly recommend using normal HTTP caching for any Javascript and images, which is pretty much perfect and fully automatic, but I suspect has it's data limit somewhat lower than what you need. The other major solution is of course to only load what is needed on demand. This depends a lot on the game, but frequently large assets like music, sounds and textures are not constantly needed (e.g. may be map/level specific).
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!