Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

776 Good

About wqking

  • Rank

Personal Information

  • Interests


  • Github

Recent Profile Visitors

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

  1. You need to make Collection template template parameter. template <typename T, template <typename> class Collection> string join(const Collection<const T> &data){ ... }
  2. I would suggest unit testing and code review may be your friends, if you didn't use them yet. If you are talking about how to handle the system (Windows, DX) API failure, then you should determine how to do it before you code it rather than debug after the failure happens. So, 1, If the failure should not happen (such as failed to allocate the memory), display some error message and quit the program. 2, If the failure is allowed to happen, deal with it. For example, if you fails to open a config file, then create it and reopen it. This is more about your program logical to handle they API failures rather than debugging it.
  3. Dynamically load the DLL using LoadLibrary and get the function address using GetProcAddress
  4. Nested components can only make your system unnecessary complicated and adds nothing else, think about the worst nested components hierarchy can be another non-ECS inheritance tree. So avoid it. In you example, fist is just an entity, not a component.
  5. What's wrong? The below code compiles fine in VS 2017. struct A { virtual ~A() {} }; struct B : public A { ~B() override {} };
  6. My Gincu game engine supports both SFML and Allegro, you may be inspired from it. The game application doesn't know the underlying engine (SFML or Allego), so it's quite what you want.
  7. class __declspec(dllexport) A {}; How about google "VC export class"? It gives you https://msdn.microsoft.com/en-us/library/81h27t8c.aspx
  8. pInt belongs to B::function() . That's to say, its scope is limited in B::function() . Though it's a pointer to member of A.
  9. wqking

    double accuracy in C++

    There is infinite real numbers, while double can only present finite numbers, so it can't present all numbers. To solve it, you need fixed point number
  10. A guess may be the server sends some data the clients can't understand correctly and corrupt the memory. Run the debug version in a debugger, then you can see the source code where it crashes.
  11. Include guards are used to prevent cycle inclusion, not to (and not need to) prevent multiple declarations (not definitions). Though as frob said, most class declarations are also class definitions so they can't be multiple in one translate unit. Here is an article on declaration vs definition.
  12. Multiple class declarations are allowed in one translate unit. So it's fine you include class A many times in one .cpp. But class definition (which define the function code, etc) must be in a single translate unit, except they are inline.
  13. https://github.com/wqking/eventpp eventpp is an open source C++ event library that provides tools that allow your application components to communicate with each other by dispatching events and listening to them. With eventpp you can implement signal/slot mechanism, or observer pattern, very easily. Facts and features Powerful Supports both synchronous event dispatching and asynchronous event queue. Configurable and extensible with policies and mixins. Supports event filter via mixins. Robust Supports nested event. During handling an event a listener can safely dispatch event, append/prepend/insert/remove other listeners. Thread safety. Supports multiple threading. Exception safety. Most operations guarantee strong exception safety. Well tested. Backed by unit tests. Fast The EventQueue can process 10M events in 1 second (10K events per millisecond). The CallbackList can invoke 100M callbacks in 1 second (100K callbacks per millisecond). The CallbackList can add/remove 5M callbacks in 1 second (5K callbacks per millisecond). Flexible and easy to use The listeners and events can be any type, no need to inherit from any base class. Header only, no source file, no need to build. No dependencies on other libraries. Requires C++ 11 (tested with MSVC 2017, MSVC 2015, MinGW (Msys) gcc 7.2, and Ubuntu gcc 5.4). Written in portable and standard C++, no hacks or quirks. License Apache License, Version 2.0 Version 0.1.0 eventpp is currently usable and near stable. Quick start Namespace eventpp Using CallbackList #include "eventpp/callbacklist.h" eventpp::CallbackList<void (const std::string &, const bool)> callbackList; callbackList.append([](const std::string & s, const bool b) { std::cout << std::boolalpha << "Got callback 1, s is " << s << " b is " << b << std::endl; }); callbackList.append([](std::string s, int b) { std::cout << std::boolalpha << "Got callback 2, s is " << s << " b is " << b << std::endl; }); callbackList("Hello world", true); Using EventDispatcher #include "eventpp/eventdispatcher.h" eventpp::EventDispatcher<int, void ()> dispatcher; dispatcher.appendListener(3, []() { std::cout << "Got event 3." << std::endl; }); dispatcher.appendListener(5, []() { std::cout << "Got event 5." << std::endl; }); dispatcher.appendListener(5, []() { std::cout << "Got another event 5." << std::endl; }); // dispatch event 3 dispatcher.dispatch(3); // dispatch event 5 dispatcher.dispatch(5); Using EventQueue eventpp::EventQueue<int, void (const std::string &, const bool)> queue; dispatcher.appendListener(3, [](const std::string s, bool b) { std::cout << std::boolalpha << "Got event 3, s is " << s << " b is " << b << std::endl; }); dispatcher.appendListener(5, [](const std::string s, bool b) { std::cout << std::boolalpha << "Got event 5, s is " << s << " b is " << b << std::endl; }); // The listeners are not triggered during enqueue. queue.enqueue(3, "Hello", true); queue.enqueue(5, "World", false); // Process the event queue, dispatch all queued events. queue.process(); Please check Github for the source code and documentations. https://github.com/wqking/eventpp
  14. The simplest solution is using a shared pointer such as std::shared_ptr, otherwise you may roll your own reference counted pointer. // pseudo code struct MyPointer { MyClass * pointer; size_t count; }; struct MyPool { MyClass * requirePointer(someKey) { MyPointer * myPointer = findBySomeKey(someKey); ++myPointer->count; return myPointer->pointer; } void releasePointer(MyClass * pointer) { MyPointer * myPointer = findByPointer(pointer); --myPointer->count; } }; But I would highly recommend using std::shared_ptr instead of your own reference counting.
  15. A vtable index is same as a function name, it's determined at compile time and won't change and of course won't be over flow. If you debug to see a virtual member function pointer, you will find it's some vtable index instead of pointer to memory.
  • 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!