Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Josh Petrie

Member Since 11 Jun 2003
Offline Last Active Private

#5206937 Is there a way to draw super precise lines?

Posted by Josh Petrie on 27 January 2015 - 10:11 AM

Review the rasterization rules and compare them to your code; they are likely related to your issue.

#5206317 Constructor gotcha's?

Posted by Josh Petrie on 23 January 2015 - 08:23 PM

It seems like the moment you start really using constructors and destructors you have to subscribe to a bunch of other OO nonsense. At least, this is my own opinion




No, you have to subscribe to some C++ "nonsense" (also known as philosophy) It's not "OO" at all, in the same way that just because you use the "class" keyword to make an aggregate type doesn't mean you are using an OO paradigm in your code.


I hate that you can't take a pointer to constructors and destructors



For good reason, as this would allow you to break some fairly fundamental rules of the language. 


Lastly C++ sucks when you define a constructor and yet want to create an array of your object on the stack and you get the error saying that's not possible without a trivial default constructor.



You need a *default* constructor (which need not be trivial); this also follows naturally from the philosophy of the language and is generally what you want. The alternative would be for you to have to have some mechanism to tediously construct every array element, and deal with the fact that an array can thus contain some constructed and some unconstructed items, opening the door for even more exciting undefined behavior.

other than that, are there any "gotcha!"s to look out for?  


The biggest mistake I see people make with constructors is failing to understand that the order of initialization in constructor initializer lists is the *member declaration order*, not the order in which members are lexically arranged in the initialization list. If you are initializing some members in terms of other members (which isn't that common), make sure to check this (many compilers will warn you about it).

#5205804 C++ Reflection/Meta System

Posted by Josh Petrie on 21 January 2015 - 11:15 AM

Whelp that can't be that hard to mimic




This made me chuckle. smile.png


The reality is not that it's hard to make a reflection system in C++. It's hard to make one that works really well, really safely, really effortlessly, and satisfies all the myriad competing needs individual developers have (or don't have) for such a system. It will always be this way, at least until the language gets more native support for some of the fundamental building blocks (although maybe not even then, depending). Instead, as you'll discover here (if you haven't already), you're going to be forced to choose between several arguably unfortunate design trade-offs which infuse your system with certain limitations. These will be deal-killers for some people, and not worth worrying about for others. It's why there are tons of C++ reflection libraries floating around. 


But that's not really want I wanted to post about. I wanted to agree with Sean on the oddity of keeping your source closed; you'll get much more in-depth critiques and suggestions if the implementation is available so people can dig through the actual implementation details and costs/benefits of your approach.


Also, what's with using screenshots of code on the ArchetypeSystem site? Its ugly and hard to read.

#5205573 Site for Code Discussion

Posted by Josh Petrie on 20 January 2015 - 11:18 AM

am I thinking it's something to do with a for loop?





Try to break a problem you don't know how to solve down into smaller and smaller components until you know how to solve one of them. For example, first think about simply printing the string backwards. How would you do that? Well, first you'd print the last character. How would you get the last character? Okay, then how would you get the character before that? And before that? See a pattern? 


Once you're printing the string backwards successfully, you've solved 80% of your original problem and now simply need to tackle the smaller problem: how do I store each character somewhere instead of printing it?

#5205390 Site for Code Discussion

Posted by Josh Petrie on 19 January 2015 - 03:23 PM

Incidentally, I'm fairly sure when I was learning years ago I was told that a string was just a char array so I was surprised that I had to convert a string to an array in the first place.  I may have remembered this wrong of course (was reading C & C++)



C doesn't have strings, it has arrays of characters. An array of characters terminated with a zero character is used to represent a "string" and there are a bunch of standard library functions that work with character arrays conforming the that definition that make up C's "string library."
C++ inherits the same convention and also adds a std::string standard library type.
Strings in other languages are usually built-in, first-class types, as they are in C#. They may conceptually be arrays-of-characters but are not trivially interchangeable with them.

Ah well I suppose I would add a conditional to make sure that times >=1.



There's quite a lot you can do to your code to harden it against errors and bad input, and a few places where you are doing slightly under-performing operations (C# strings are immutable, it's generally better to get into the habit of using string.Format or the StringBuilder class to format them, as stuff like "string" + thing + "string" potentially creates a lot of garbage, for example).

#5205362 Site for Code Discussion

Posted by Josh Petrie on 19 January 2015 - 01:34 PM

This site is a pretty reasonable place to ask for feedback on your code.


The Code Review StackExchange site may be appropriate for certain things as well (read the help center though).

#5205321 College degree and Job in the game industry

Posted by Josh Petrie on 19 January 2015 - 10:44 AM

how hard would it be for a graduate from an acredited regional university, ranked 23 in college us rank and with a degree acredited by the Aacsb (Association to Advance Collegiate Schools of Business) to compete with an individual with a degree from a Ivy League University such as Harvard?



Different hiring managers and HR processes will put different weight on your educational qualifications (I, for example, wouldn't consider the two you listed any differently: in my thought process you either have a degree or you don't, and we go from there, unless your degree is from a few select places that I've had bad experiences with -- "game schools" mainly).


Generally the education part of your resume is useful only for passing the initial (often HR-based) resume screen, and beyond that you will get the job or not based on what happens in the interview itself. Once you have had a job in the industry, your education is considered with even less weight.

#5204952 Becoming a game engine programmer

Posted by Josh Petrie on 17 January 2015 - 02:04 PM

What do you think an engine programmer is?


Game development studios are nontoriously fast-and-loose with their titles. An engine programmer at one studio may be focused entirely on graphics, in another studio they may be focused on core technology like memory management and crash reporting, in still another they may do some combination of both, or may be the programmers responsible for the shared technology across all games whereas "game programmers" are working on specific titles (even if both programmers do the same basic work in the same basic domains).


So what is it you want to do? That's more important to the issue than what you want to be called.

#5204742 Returning a nullptr refence, how bad is my teammate?

Posted by Josh Petrie on 16 January 2015 - 11:31 AM

We've probably been over this before, but why isn't this covered by the most important const thingymajig?


(The reference to temporary thing isn't really much of an issue since it's const, so its lifetime is extended to the lifetime of the reference.)


Only local const references extend the lifetime of a temporary. In Sutter's first example there, f() is returning a string by value; a copy of the string constructed from "ABC" is on the stack and the reference "s" extends the lifetime of that copy to the scope of s itself. That doesn't apply in the above situation (which is why the compiler warns about it).
The standard, in 12.2/5 (class.temporary) says that "the lifetime of a temporary bound to the returned value in a function return statement (6.6.3) is not
extended; the temporary is destroyed at the end of the full-expression in the return statement."

#5204580 Returning a nullptr refence, how bad is my teammate?

Posted by Josh Petrie on 15 January 2015 - 04:22 PM



Your compiler should be warning you that you're returning a reference to a temporary. If it isn't, get a better one, and make warnings errors.


 I am very interested what is your opinion on returning a reference that is nullptr.



That's not what that code is doing, per se; that code is creating a std::string temporary out of the null pointer (via the constructor that takes a const char *) and returning that.



how bad is my teammate?



I wouldn't be too quick to judge, it would be easy for this code to come into being via a refactor that changed to std::string from using C-style const char* strings, or any other number of incremental changes. The real problem is that you're not compiling with the tools to catch these issues (or you are, and you're letting people check in with compile errors or without compiling). Either way the larger failure is on the process, and calling him a bad programmer isn't (necessarily) fair.


There are other flaws with the code as well (you search the map twice, once in the find call, and then redundantly again in the bottom-most return call where you can instead make use of the iterator).

#5204563 Where should i start with programming?

Posted by Josh Petrie on 15 January 2015 - 03:42 PM

i'm never doing python though, just don't ask...



That seems like a silly attitude. Good programmers know many languages and generally do not let superficial or political issues get in the way of using one if it is the proper tool for the job. And comments like that strongly imply a superficial or political bent to whatever your issue with the language is. Since you don't know it, after all.


Also do you recommend any C# books i can start off with?



There's a good collection of material from the MSDN here. I don't have any books to recommend for beginners, but there's a few linked on the MSDN site that are probably perfectly acceptable.

#5204552 Where should i start with programming?

Posted by Josh Petrie on 15 January 2015 - 03:24 PM

I would strongly recommend against C++ as a first language, it is not beginner-friendly and it is not forgiving. C# or Python would be better options.


That said, regardless of which language you ultimately choose to learn, everybody learns differently. Some people swear by YouTube-based tutorials as a means of acquiring new knowledge. I personally can't stand them. Getting started, books and online introductions are likely to be your best option since they will tend to be more comprehensive in their overviews and educational rigor. Once you move beyond the basics and can build simple programs (like a "guess the number" text-based game) on your own without consulting the book, you can move on to material that better suits your style (such as video-based stuff if you are into that). 


Be aware that (especially for C++ given its age and complexity), there are a lot of really bad "tutorials" out there.

#5204530 100% New to Game Deving... 0% Idea Where to Start

Posted by Josh Petrie on 15 January 2015 - 12:42 PM

the platform i will be using is RPGMaker or something similar



Usually these sorts of "game construction" tools support only one (or a small number) of scripting languages. Modern versions of RPGMaker, for example, use Ruby (or something Ruby-like). 


So you should pick the tool you're going to use first, and then learn whatever language it demands of you for scripting your games. Usually the tool in question will have documentation or tutorials that can get you started with the scripting aspect.

#5204502 Open Source Game With Copyright Questions

Posted by Josh Petrie on 15 January 2015 - 10:22 AM

That's the thing right there, I have played DC Universe Online for a very long time because after playing Champions Online I quit the game and started playing DC Universe Online. Every single "Hulk" I seen has never gotten a report from a player. Every friend I have in there whose character is based off an iconic character (Capitan America, Wolverine, Iron Man as you said, and so on) that are not DC Comics based have never had their account banned or suspended, and some of them have their account full of iconic characters, meaning everything time they jump in the game they are playing on an iconic character



None of that matters though. Those players signed an agreement. They are now in violation of that agreement, which means they are no longer permitted to play the game (that's what the agreement says). Just because they have not yet had that punishment enacted does not mean that they won't eventually or that it's okay.


Now this is the two main things I do not understand and also the main things that has me confused with all this copyright stuff, how DC Universe Online get away with it all and Champions Online can't


What you aren't understanding is that both games are doing more-or-less the same things to proactively try to defend themselves against IP litigation (they are probably doing more behind-the-scenes in terms of deals and communication that you cannot see). You're only a player of those games, you are given extremely little insight into what's going on within those studios in the operation of those games. Just because you have never personally observed (or heard of such an observation from your friends or community) such a ban doesn't mean it hasn't happened. It just means you haven't seen it. Perhaps DCUO has a more subtle internal policy for dealing with the situation. Perhaps they are just collecting a large list of accounts to ban and will do them all in one fell swoop at some future date. 


Even they legitimately have not done anything to ban IP-infringing characters yet, they have still put themselves in a position where they can trivially do so if they need to.


If you are really set on creating this game in the fashion you originally described I strongly advise you to hire a lawyer, preferably one with extensive experience in IP law. Your own understanding is dangerously flawed and could result in years of work down the drain in some cease-and-desist or (worse) litigation. Don't risk your time like that, it's worth too much.

#5204389 Open Source Game With Copyright Questions

Posted by Josh Petrie on 14 January 2015 - 09:32 PM

 The only main thing I find strange is how Champions Online have this issue, yet DC Universe Online doesn't has it at all and they are far more known that "Champions Online" since all the characters in CO are practically made up right for the game itself.



Ah, but DC Universe Online does have this issue. And, like Bethesda did for Skyrim's tools, they proactively protect themselves against IP litigation by (among other things) including this clause in the EULA you agree to when you play DC Universe Online:


11. As part of your Account, you can upload content to our servers in various forms, such as in the selections you make for the Game, in-game posts and chat, and in chat rooms and similar user-to-user areas (collectively, your "Content"). Your Content shall not: (a) infringe any third party intellectual property, other proprietary or publicity/privacy rights; (b) violate any law, rule or regulation;

In other words, you can't make Iron Man in DC Universe Online.