Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

199 Neutral

About SeiryuEnder

  • Rank
  1. SeiryuEnder

    Server Exception Handling

    Sorry, didn't have much time last night. Our server is using a thread pool, when we receive a network request we assign a thread to handle it. This can include sql queries, movement updates, game objectives, etc. Ideally our exception handling will be as comprehensive as possible so as to quietly handle any soft hardware or database failures. At the very least it will be used to resolve external problems. It'd be nice to use asserts to fix any programming errors and EH to handle any external problems, however due to the nature of servers we prize stability over all else. An offline is 0% efficient, so we're willing to sacrifice some performance while we fix the broken things.
  2. Hi, I'm currently researching exception handling, and will be implementing it on a heavily threaded game server in the near future. Here is what I will need: Safely unwind stack, high server stability Low overhead Works well in a highly threaded architecture While I am researching and have used EH before, I haven't gotten very in-depth with it and am not yet very familiar with what happens under the hood. Are there any red flags I should know about, any good book references for this sort of thing, or any ideas about how I can more effectively implement EH rather than just toggling some /EH_ flags? I realize this thread is a bit open ended, the problem I suppose is that I don't yet know what questions I should be asking and hope to pick the brains of those more experienced with this sort of thing. Thanks~!
  3. SeiryuEnder

    Using C++-Allocated Objects in Lua

    I started out trying ToLua++ and Luabind until I found out they both use the Boost libs. Because of the bulkiness I've tried to stay away from Boost but unfortunately I may have to bite the bullet on that one... I much prefer Boost+Type Safety to no Boost+Bad Design. Your implementation looks exactly like what I wanted to do in the first place, I guess I'll back up/revert my Luna code and start working on ToLua++
  4. Right now I'm using Luna to expose my C++ classes to Lua. The problem I'm having is that I want to allocated and manage my objects in C++, only using Lua to potentially create or manipulate them. I'm not particularly familiar with Lua. My (rather naive) first attempt was to set up a class as per some Luna tutorials, create that class using a factory, pass that class to Lua using lua_pushlightuserdata, and create an object reference in lua to the pointer in the stack. As it turns out, Lua doesn't know how to interpret that pointer as it defines 'objects' by metatables which a raw memory address won't have. After giving it some thought, I'm currently considering creating an interface class which contains all of my Lua functions. The constructor will accept a parameter to its target class. Because it is only an interface and doesn't contain any actual data, it doesn't cost much to instantiate it whenever a script is run and let the GC clean it up. However, not only does this seem inefficient but I completely lose type-safety. The script could theoretically pass anything into the lua interface which can crash the program (or worse). Does anyone more experienced with C++-Lua binding know how I can achieve my original goal of handing a C++ object to lua, or have any more elegant solutions? I'll add some pseudo-code below to make my problem a bit more clear. Current Attempt: std::vector<GameObject*> objList; class GameObject { public: void DoThing() {} int Do( lua_State* _state ) { DoThing(); } ... insert Luna binding code } int CreateObject( lua_State* _state ) { GameObject* obj = new GameObject(); objList.push_back( obj ); lua_pushlightuserdata( _state, (void*)obj ); return 1; } int main() { lua_State* state = luaL_newstate(); lua_register( state, "CreateObject", CreateObject ); luaL_loadfile( m_State, "DoSomething.lua" ); lua_pcall( state, 0, LUA_MULTRET, 0 ); lua_close( state ); return 0; } DoSomething.lua: local obj = CreateObject( "LuaScript" ) obj.Do() ...This won't work because Lua doesn't know how to interpret that (void*), I incorrectly thought that it would maintain some sort of VFT-esque behavior. The method I talked about as a potential solution would be something akin to: class GameObject { public: void DoThing() {} }; class LIGameObject { public: LIGameObject( GameObject* _target ) : m_Target(_target) {} int Do( lua_State* _state ) { m_Target->DoThing(); } ... insert Luna binding code private: GameObject* m_Target; }; int CreateObject( lua_State* _state )... int main()... DoSomething.lua: obj = LIGameObject( CreateObject( "LuaScript" ) ) obj.Do()
  5. SeiryuEnder

    Simple ListView Inventory Question

    Just to piggyback on mikeman's code a bit, to add multiple items you could do something like this: public struct GameItem { public static string Name; public int Energy; public int Damage; public int Value; }; ... lvi.Tag = new List<GameItem>(); lvi.Text = GameItem.Name; lv.Items.Add(lvi); ... List<GameItem> itemList = (List<GameItem>)lvi.Tag; int quantity = itemList.Count; foreach( GameItem item in itemList ) { // Do thing with individual item } ...
  6. You can always make the game in flash and call JavaScript externally to drive your logic. Flash is attractive because of how rapidly you can set up and develop an application (very in-depth GUI), JavaScript is attractive because of the lower level control. I don't think there's a good reason not to have the best of both worlds. It obviously won't be as efficient as everything being done in JS (interop never is), but you're not normally too worried about optimization in Facebook apps. It's more about production efficiency.
  7. SeiryuEnder

    Main game loop design

    That depends on the object.. Generally you have an ObjectManager that contains a list of Object*. Then you have other objects that derive from the parent object and do different things. Something like this (untested code): class Animal { public: virtual void Talk() = 0; }; class Cat : public Animal { public: void Talk() { say( "Meow" ); } }; class Dog : public Animal { public: void Talk() { say( "Woof" ); } }; class Bird : public Animal { public: void Talk() { say( "Chirp" ); } }; class AnimalManager { public: Add( Animal* _animal ) { m_Animals.push_back( _animal ); } AllTalk() { for( int i = 0; i < m_Animals.size(); ++i ) m_Animals->Talk(); } private: std::vector<Animal*> m_Animals; }; int main() { Cat cat; Dog dog; Bird bird; AnimalManager mgr; mgr.Add(&cat); mgr.Add(&dog); mgr.Add(&bird); mgr.AllTalk(); return 0; } Simple Event System Different people handle it different ways. Some people move the collision check out of the object and make it part of the object manager. Some people do it through events, and keep track of objects they've collided with that frame so that they don't multiply collide. There are other solutions as well. Do a little Googling and find a solution that works for you.
  8. SeiryuEnder

    Main game loop design

    That's a highly procedural approach. Generally my update loop will go something like (this is complete pseudocode mind you...): void Game::Update( float _delta ) { m_Input.Update(); m_ObjectManager.Update( _delta ); m_Sound.Update(); m_Render.Update(); // <== Does the actual rendering m_Events.Update(); } void Object::Update( float _delta ) { HandleInput(); UpdateAI( _delta ); UpdatePhysics( _delta ); UpdateRenderInfo(); // <== Update render information, doesn't actually render the object } Bear in mind there's a really good chance I'm missing something, but the logic behind this ordering is as follows: Update Input first, as Input may raise events and needs to be readily accessible to other systems. Update Objects second, they may create/play/stop audio assets and have to tell the renderer what to do. Update Events last so that any events raised by other systems can be handled. If I could offer some advice though... Don't worry about throttling yet. Worry about optimization once you get things working.
  9. SeiryuEnder

    What Order To Code In?

    I couldn't agree more with JTippetts. Game programming is going to really challenge your self discipline; there's an uncountable number of projects scrapped because of lost interest. If you're not constrained by milestones and deadlines, do whatever motivates you at the time. Don't leave unfinished code - wrap up whatever you're working on - but generally it's a bad idea to keep working on something if you're deadlocked or just really disinterested. The biggest thing to keep in mind about the UI is that it is purely about FEEDBACK. It is 100% INFORMATIVE. I typically open a console (will add some code for that below) and make that last until many of the core systems are in place/functional. As for the UI, the most critical thing you can do is sit down and DRAW OUT YOUR UI ON PAPER!! Seriously, don't skip this step. Draw it a few times. Make changes on paper. It will save you so much time. You will almost certainly go through several revisions, but you want to be as prepared as possible. Generally speaking, for every hour you spend designing you will spend 10 fewer hours implementing. -edit Almost forgot to add the console code. There's a couple ways of doing this. The easiest (if you're using visual studio) is to go to: Project Properties -> Linker -> System and set your subsystem to console. In the older version of MSVC that would allow you to open a console window while running an application. If you have trouble with that or it's not an option for you, you can also add this code to your WinMain: #if defined(_DEBUG) // Open a debug console window HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); int hCrt = _open_osfhandle((long) handle_out, _O_TEXT); FILE* hf_out = _fdopen(hCrt, "w"); setvbuf(hf_out, NULL, _IONBF, 1); *stdout = *hf_out; HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE); hCrt = _open_osfhandle((long) handle_in, _O_TEXT); FILE* hf_in = _fdopen(hCrt, "r"); setvbuf(hf_in, NULL, _IONBF, 128); *stdin = *hf_in; #endif From there, you should be able to use std::cout to print to the console
  10. SeiryuEnder

    Defining Entities using XML/Lua

    Yeah it's a bit of a complex problem to describe without coding examples. The only real reason for using XML right now is that at some point I intend to support other scripting languages such as Python. XML acts as a simple layer of abstraction between the game and the scripting language. The problem was twofold - my lack of understanding how to properly use Lua and how to initialize my components. For instance, until now I've done something like this (just to get things running): Entity* ent = new Entity; Cmp_Transform* cmpTransform = new Cmp_Transform( ent ); Cmp_Mesh* cmpMesh = new Cmp_Mesh( ent, "SomeMesh.gmx" ); ent->AttachComponent( cmpMesh ); ent->AttachComponent( cmpTransform ); ent->Initialize(); I moved the constructor args to an Init function so that I could use the default constructor. Now, I can register components to an object factory and create them like this: Factory<IComponent*> factory; factory.Register<Cmp_Transform>("Transform"); IComponent* cmp = factory.Create("Transform"); Entity entity; entity.AttachComponent( cmp ); With a simple glue function I can create any registered component by knowing its name, which gives me a lot of flexibility from the scripting end. The problem was, I couldn't call an Init(...) function from the C++ end because it is a member function of an unknown derived class. I think I've finally figured this one out. I've set up Luna to bind component member functions to Lua, and I'm going to push the component pointer onto the stack. From there I should be able to call the Initialize function. I haven't gotten that far in code yet, but theoretically it should pipe to the proper function where I can at least check the number of arguments and hopefully later enforce better type safety.
  11. SeiryuEnder

    What Order To Code In?

    I'm not familiar with CoronaSDK, but usually my dev cycle is something like: Barebones world (just some land) Console output, relevant debug text Simple collision/Input More complex UI Refine World Refine UI Repeat 5-6 until gold 'World' refers to general features like rendering or audio. In a production environment normally you have a set of features you're responsible for, so knowing what to work on is rarely an issue (esp. with publishers ) The advantage of working indie is that once things are working on a very basic level, you can decide what you want to do when you want to do it. If I could offer some advice though, try not to be too jumpy between systems. Lots of bugs happen that way.
  12. I've been developing a data-driven Entity/Component system in C++ using Lua. There's been a lot of good documentation out there, but I've hit a bit of a snag with Lua. -edit 1: [indent=1]My problem is likely to do with the need to bind classes to Lua rather than using a factory to create components... Still doing research on that -edit 2: [indent=1]After some thought and playing with Luna, I'm going to try registering components with my factory and feeding the base pointer address back to Lua. [indent=1]From there I should be able to call the expected mapped function. I don't know what kind of error handling this will have (if any), but at least it's moving in a direction. Summarized Question How do I create objects with a C++ factory using Lua and define necessary parameters while maintaining type-safety? My goal is to be able to determine at runtime if there is a parameter mismatch when defining a component. More Information The system works like this: Open OnLoad.lua -OnLoad.lua loads _Level_.lua --_Level_.lua loads and posititions Entities in the world ---Game parses XML file for (each) Entity definition [One of two ways to handle this] A ----Entity tag references _Entity_.lua -----_Entity_.lua loads components OR B ----Entity tag body contains a list of components along with component property definitions Problem 1: Not a huge problem, but a mild design question. Method A is more expandable (Lua can perform other actions when loading different types of entities, may be useful), but Method B is simpler and centralized. Right now I'm leaning towards defining entities in Lua to err on the side of caution, as I may need the extra functionality later. Which do you think is the preferable method? Problem 2: I'm stuck on how to actually construct the components. I'm sure there's a simple solution, but for some reason it eludes me. Different components may need different parameters. For instance, I may need no parameters at all for a Timer component but will need a name/ID for a Mesh component. I'd like to figure out a way to register the component with my object factory but that would mean having to have a default constructor and defining a different Init(...) function for each type of component. When I create the object with the factory I will get a base class pointer back, so I have no (type-safe) way of knowing what parameters the init function will need. I'm just not making the connection on how to define properties of a component in XML/Lua then pass that information to its appropriate place in C++. I've considered more elaborate methods of defining property tables in my components, but that seems inefficient and overcomplicated. As always, thanks in advance for any help!
  13. I didn't realize this was such a tumultuous legal issue... I knew generalized patent laws were out of hand but this is just absurd. I'm surprised someone hasn't patented breathing. We can only hope that big-business money mongers will eventually realize that inhibiting progress like this is just shooting themselves in the feet. FYI: Bink is really easy to implement, I recommend it if you've got the $8,500 in your budget.
  14. SeiryuEnder

    2d Game Death Animation Ideas

    There's also full-screen effects to consider. The world can grey out, you can do a 'spotlight' effect, etc etc.
  15. SeiryuEnder

    Engine-Tool Runtime Communication

    I hadn't considered a networked solution for communication... I rather like this. If I recall correctly, the PS3 devkit uses a similar method. This actually opens up some pretty neat possibilities. Theoretically, two or more people could work in tandem creating and/or playtesting on the fly. I still haven't gotten around to making a networking component for my engine yet, but a barebones Berkely sockets system shouldn't be too hard to drum up just to get things moving. I still have to figure out a way to get a C++ engine to render to a C# surface -- but that's another creature entirely.
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!