Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Jun 2000
Offline Last Active Today, 08:58 PM

#5316515 Language decision crisis

Posted by on Today, 03:07 PM

... plus you have access the widest range of libraries.


Good point... if only there was some way to access C libraries from C++!


Don't listen people saying "ommg in C you have to do yourself your memory management", really it's only 2 functions (malloc & free), nothing to worry about...


I know, right?! I mean, it's like a gun... they only have one button... no way that could cause trouble if you don't know what you're doing!



#5314439 Best way to be a game developer?

Posted by on 09 October 2016 - 01:24 PM

Some sage advice:


"...on how to be a professional boxer. A good diet is essential, of course, as is a daily regime of exercise. Pay attention to your footwork, it will often get you into trouble. Go down to the gym every day – every day of your life that finds you waking up capable of standing. Take every opportunity to watch a good professional fight. In fact watch as many bouts as you can, because you can even learn something from the fighters who get it wrong. Don’t listen to what they say, watch what they do. And don’t forget the diet and the exercise and the roadwork.
Got it? Well, becoming a writer game developer is basically exactly the same thing, except that it isn’t about boxing."
---Terry Pratchett
I love this quote because I feel like you can apply it to almost any vocation :)

#5312955 Coding-Style Poll

Posted by on 27 September 2016 - 09:27 PM

If you want an example of something hellish: Go determines the scope of a function name (global or local) based on whether its name starts with an uppercase letter or not. Just... why? x_X Pretty much every other language lets you avoid that so huh, consider not doing it =O) I could see that becoming an ugly mess in the long term. (also I hate languages that enforce coding styles, they're subjective and prone to evolve over time, forcing them in the language literally prevents the ability to improve over the quirks even for new projects)


Actually, I don't have a problem with that at all. It becomes immediately obvious upon seeing a function what it's scope is. 


As for languages that enforce coding styles, part of me thinks it's a ddamn fine idea, if only so we don't have to waste time with discussions like this. 


Should the brace go on the end or on its own line? Whichever one compiles!

#5312906 Coding-Style Poll

Posted by on 27 September 2016 - 02:39 PM

Worst case is I run the code through a source formatter after checking it out, then again before checking it back in.  Takes a couple of seconds, no big deal and definitely not worth getting upset over.


As long as your source formatter is perfect, i.e. reversing it will give back the exact same code as you started with.


Otherwise, you will end up with a version history littered with meaningless changes.

#5312173 How to use Unit-Tests

Posted by on 23 September 2016 - 03:44 PM

Well, in order to test my classes, I would have to implement or rather copy them from the original project.
Is that right or is there any possibility to refer to my original files which saves rewriting/copying a class?
As the projects are separated, I doubt this is possible though.

Typically you'd put the thing you want to test into a library project (static lib, dll, whatever).

You would then have an executable project that contains the tests and runs them (depending on the testing framework; some frameworks load dlls into a "test runner")

Finally you have your game executable which just loads your games library and starts it.

So in visual studio, something like
+ SuperAwesomeGameStuff (library)
- all your game code goes here
+ SuperAwesomeGame (exe)
- just basically has a "main" that starts your game
+ SuperAwesomeTests (exe)
- contains all the tests and runs them

#5311571 Why C# all of a sudden?

Posted by on 20 September 2016 - 03:01 AM

Outside of games: You're late. C# has seen widespread use in client software development for a long time.

Not just client. It's been popular in server side for at least 10 years now (between "web methods", WCF, and lately ASP.net web APIs).

#5310639 Why can't I print out my std::string vector?

Posted by on 13 September 2016 - 03:24 PM

Should I still not do this even if many other classes needs MapManager? (sorry for the super late reply...)

You've fallen for the most common misuse of the singleton pattern. The singleton is there is ensure a single instance of an object, not a single point of access.
Everyone who misuses a singleton in this fashion says the same thing: "I don't want to pass my X/Manager/God/Controller/Whatever object everywhere". As @Álvaro said, at least then your dependency is obvious.
If you find that you're passing a certain object everywhere down through layers of code, this is a code smell and a sign that you should refactor your code.
That said, sometimes a global really is the lesser evil. Things like a log object for example.
But let's say you look at your options and you decide that it really would be less painful to not pass MapManager everywhere. In that case, just create a global and own that decision. 
You have you MapManager class defined as normal (MapManager.h/.cpp). These files should know nothing about the global, otherwise you can't use them without it.
Create a header where you will declare your global MapManager

#include "MapManager.h"

// namespaces are great!
namespace InsertGameNameHere
   namespace Globals
      // the global map state
      extern MapManager TheMap;

Then in your main.cpp instantiate TheMap

#include "Globals.h"

// instantiate the map. this should be in exactly one place in the code
MapManager InsertGameNameHere::Globals::TheMap;

int main()
   // do more stuff

Anywhere else you need to access the map, just include Globals.h without instantiating the map.


#include "Globals.h"

namespace InsertGameNameHere
    void SpawnMonster()
       Monster monster;
       // etc.

#5305806 Pre-emptive Solution for 'The application was unable to start correctly (...

Posted by on 14 August 2016 - 04:28 PM

I am linking the static OpenSSL libraries so shouldn't I not need to distribute the dll with my installer? Shouldnt it be packaged into the exe?


My Linker->Input->Additional Dependencies are:










Bear in mind that libraries with a "d" at the end are generally debug libraries, and you probably don't want them being used in the release version of your code. 

#5303860 Xml Parser, C++

Posted by on 03 August 2016 - 03:37 PM


 Advantages of TinyXML-2
Many fewer memory allocation (1/10th to 1/100th), uses less memory (about 40% of TinyXML-1), and faster (~5x on read).



I tried TinyXML-2 and it's still a memory hog. The conversion from TinyXML was very easy.


TinyXML is a DOM based parser. This means it has to load the entire document into memory first. For a lot of applications, that's fine (desirable even).


If memory is an issue, you could look at a SAX based parser, which uses an event-driven model to process the XML. This uses less memory, but it isn't as easy to program with (in general, YMMV).


For C++ sax parsers, you can use Xerces or Libxml++ (there may be others, those are the two I have used).

#5303575 Xml Parser, C++

Posted by on 01 August 2016 - 08:02 PM

One problem that I have with TinyXML is that it takes up 1.6+ GB of RAM to parse a 346MB XML file.

Might be worth looking at TinyXML2 then?

Advantages of TinyXML-2
Many fewer memory allocation (1/10th to 1/100th), uses less memory (about 40% of TinyXML-1), and faster (~5x on read).

#5303559 Xml Parser, C++

Posted by on 01 August 2016 - 04:29 PM

I've even written a C# wrapper for CMarkup, and use it in a number of .NET projects.

What advantages does CMarkup have over the .Net XML libraries? 

#5303040 Xml Parser, C++

Posted by on 28 July 2016 - 10:24 PM

What have you used to parse XML files in C++?

Exactly what do you want to do with these parsed XML files? 


If you just want to read the XML into a data structure, TinyXML is simple and lightweight.


But it doesn't do schema validation or XSL transforms.


Libxml and Xerces will (I think, been a while since I used  them), but it's not as easy to use. 

#5301299 A Struct That Contains A Delegate With Unknown Signature

Posted by on 18 July 2016 - 09:40 PM

Stop and think about what you want to achieve. 
So you want to have commands that invoke delegates that potentially take arguments and return some values.
Where are you going to get the argument values from?
What are you going to do with the return values? 
IF you can explain what you want to achieve better, than we might be able to help you.

#5300081 Finding that balance between optimization and legibility.

Posted by on 10 July 2016 - 10:54 PM

I have the luxury and flexibility to do what I want and try to challenge conventional thinking. In so doing I've discovered pros and cons for going against the norm as well, and i will take the route of least resistance (wether it is a conventional approach, or something to the contrary).

Nothing wrong with that. Just be aware that there are often very good reasons for conventions. They frequently encode a lot of lessons learned the hard way.
By all means, challenge them, but do so understanding why they are conventions in the first place.

For me personally (and in my own subjectivity), I've found working within the confines of the C++ and OOP in general to be quite problematic.

And on the flip side to what I just said... no-one is forcing you to write C++ in an OOP manner. 


If you're writing something and you think it should be a free function/struct/other "non OO" construct, write it as such. 

It is one of the strengths of the language that it doesn't force you into OOP, unlike Java or C#. (I love C#, but I find it stupid that I have to create a static class to write a simple function).


#5297374 what means these error?

Posted by on 20 June 2016 - 03:40 PM

What does your debugger tell you? Not the output, the actual debugger. Step through the program until you get to the line that is causing the problem.

Look at your data.