Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

  • Days Won


Alberth last won the day on April 2

Alberth had the most liked content!

Community Reputation

9634 Excellent


About Alberth

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

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

  1. Alberth

    Parse / Split a HUGE file?

    You're not trying to commit all data in a single commit are you?
  2. I don't know how yaml cpp works, but at first glance it looks like you can build it separately as library (without debugging stuff), and then link it with your application. Obviously you won't get debugging facilities in the yaml-cpp code nor get any useful srtack-trace in case of a crash there, but your primary interest is not in debugging yaml-cpp
  3. Alberth

    Failing to create shader - help

    Using Eclipse rather than visual studio, but I disabled automagic "enrichment" on hover. I will ask for a popup if I want one, thank you very much! Sure you shouldn't post in Coding Horrors?
  4. Alberth

    Java begginer question

    Please format code using the 'code layout' (the <> brackets in the editor), code isn't readable this way. This is a standard gotcha when you switch to reference-based languages, like Java, Python, or C# (and likely a few others). What you need to get your head around is that "MyClass c" is not a value, it's a pointer to a value managed by the JVM. You can see this by realizing my "c" is currently not filled, "c.myValue = 3" will crash the program on a NullPointerException. Also, you need "new MyClass()" to make a MyClass instance. More concrete: // Assume MyClass.java exists. MyClass c; // Still empty. Myclass d; // Still empty. MyClass e = new MyClass(); // e refers to the created instance. c = e; // c refers to the same instance. d = e; // d refers to the same instance. // Assign new value to a member of the instance d.myValue = 3; // Since c and e refer to the same instance, they also have the new myValue 3. So while you never write "*c->myValue", you are effectively working in dynamically allocated memory in C++-speak. In your code, you make 32 references to the same emptyFrame object in the same list. If you change the obect from one list-entry naturally they all change. If you want to have independent DayTimeFrame objects, allocate new objects in the loop: List<DayTimeFrame> dayTimeFrames = new ArrayList<DayTimeFrame>(); // Some suggested changed to the line above // 1. Use the List<> interface as much as possible rather than the ArrayList<> implementation class. // It makes cleaner code, and changing ArrayList for another kind of list becomes much simpler. // // 2. Make your life much simpler by using plural form for container variables, and singular form for variables that hold a single instance. // for (DayTimeFrame dayTimeFrame : dayTimeFrames) ... looks more natural than // for (DayTimeFrame dtFrame : dayTimeFrame) ... doesn't it? for (int i = 0; i <= 31; i++) { dayTimeFrames.add(new DayTimeFrame()); // Make new object for each element! } Note that unlike in C++, "new" is a quite cheap operation in Java, so don't be afraid to use it.
  5. Loading the front-page takes around 15 seconds here, before the browser (firefox at a desktop) shows anything from the site. It usually continues to load more several seconds afterwards, probably stuff further down the page. I noted it seems to load the full stories (or at least a large part) of the list 'recent <something>' at the front page, and then a script kicks in to show just the first 2 or so lines. That looks like a waste of bandwith!
  6. Alberth

    Why are enums broken

    enum classes enforce that you cannot construct new values from them, unless you cast. The primary reason is to make it explicitly visible in the source code that you're using enum names as integer values rather than as a symbolic name (where the value is not very relevant). In other words, it eliminates the gap of using enum values as hidden constants. C++ being C++, it's of course not impossible, you can add casts, and hide such things in an overloaded operator. The point is however that you should consider whether your enum class is really an enum class, or that a set of (integer) constants would be more fitting.
  7. One pixel for you Edit: I think it's just what you make of it, some give lots of pixels to everybody, while others save them for special occasions. Personally, I consider pixels as just another random statistic of the site; I answer to exchange knowledge and ideas, not to collect pixels.
  8. Another way to find the problem is to draw a dependency tree. Each include file is a square on paper. From each square, draw an arrow to other squares it directly includes (ie there is an #include line in the file at the back of the arrow). You should not be able to follow the arrows and end up in a square where you have already been (ie cycles are not allowed)
  9. You'd need to have the regions themselves first, don't quite see how to automate that, perhaps semi-automatic flood-fill of an area until you hit yellow or dark colour. From there, you can probably look for neighbouring pixels that belong to another region. Not sure it's worth the time, doing it manually isn't that complicated, and you don't even need the regions precisely in that case. (Although it may be nice for a player to easily select a region by clicking it on any spot.)
  10. Ok, I hope that works better for you. If you want more information about what is going on (so you can understand what the error is about at all), you should read about how a C/C++ compiler works, with compile steps and linking steps, and how libraries are resolved.
  11. The perfect solution in one go, you do like to set high standards You realize that while there are close to infinitely many working solutions, there is only a handful perfect solutions? It's very hard to get one of those. I normally go for a working solution first, and then for a good-enough working solution. (It's normally way easier to improve something that already works, than it is to come up with a working good-enough solution out of nothing.) Depending on how important the part is, "good-enough" can be close to "working", eg for code that you use only a few times it's not worth the time to improve it, anything "working" will do. For core parts that are used all the time and that must work correctly every time, "good-enough" is much closer to (but not equal to) "perfect", which means I spend more time on getting an acceptable solution.
  12. Another option is to generate a C/C++ file with the actual text in a string literal or an array. Works for every C/C++ compiler at every platform without the need for object file tools.
  13. If you had written about how you get stuck between the ball and the manager, we could have pointed out where your reasoning runs off the best path (for some value of "best path"). Right now, there is so little information, I cannot give you much more than general feedback. Likely your problem is a not-so-fixed idea of what the responsibilities of a ball class and a manager class are exactly. When you go down into pseudo code then, the added complexity of the lower level details make a mess, as you're trying to solve several problems at the same time (namely, what should each class do, how do they interact, and how to code that at the implementation level), with, for added fun, you get additional side problems like memory allocation problems, reference management, and performance. Not sure I understand what you mean here. A class is like a template, and an instance is the result after applying the template. So while there is a relation between classes and their instances (namely the latter were created using the former), but what does "will be attached" mean? Does the object have a reference to its class? If so, why? Yep, sounds ok, the ball handles its own behavior, something else deals with the overall game mechanics. "Manager" tends to be a dangerous word here, as it's so generic, it can easily become a "everything else goes there" target, and you end up with one big blob of functionality with a quite unclear name "manager code". If possible, try to find subsets of this manager thing. As a suggestion, what if you make a "spawning manager", "modification manager", and a "destroyer manager"? (not sure the latter is needed, a ball can very well destroy itself, wouldn't it?) Decisions here should follow the guidelines of the decided responsibilities above. In other words, for each thing, decide whether it is "basic behavior" and whether it is "handles any modifications, spawning, destroying of balls". If you find one of them applies, it's simple. If you find both apply, then either "basic behavior" and "handles any modifications, spawning, destroying of balls" have an overlap of functionality, or "thing you're adding" is a composition of at least two smaller things. If there is overlap, change the responsibilities to eliminate the overlap, if it is a composition break thing in more pieces. If none of "basic behavior" and "handles modification etc" applies, you found a hole. There is a thing which nobody is responsible for. Either some responsibilities are missing, or the definition is too tight, and needs to be expanded somewhere. Simple eh? Actually, it's not simple. What you're doing is to look at ball management in detail, and lots of details pop up with new unexpected problems that need to be covered in some way. Everything must be placed in some structure that is yet unknown too. It's an exploration process, discovering what you really need, and what a good structure is to cover all your needs. Unfortunately, the latter is mostly found by either deep thinking beforehand (with severe limitations as we are less good in structuring new unexpected detail problems than we think we are), or by finding a proposed structure doesn't fit, as it fails at some point. The best you can do is adjust the designed structure to avoid the new failing point, and change the code accordingly so all "things" are at the right spot again wrt to new structure. Then continue adding other things, until you run out of things that need to be in there, and you're done! Right? Well, sort of. Obviously, you have working code now, so you can do other stuff now. However, realistically, you only found the first structure that covers all needs for ball management. You found this structure by an iterative process of incremental minor shifts in the responsibilities until all puzzle pieces fitted. A good exercise here is to sit back, and reconsider the design. "Knowing what I know now (the actual set of things that are needed), if I had to start from scratch again, would my responsibilities design be what I have now?" The usual answer (for me at least), is "no". I often decide to name the current solution "attempt_N", and do the entire exercise again as attempt_N+1 using the improved design. This may sound like a lot of work, but it's much less work, in fact. You know the end-point where you want to end up now (ie the design of the responsibilities in the classes) , you know what "things" must be covered, all you need is to do is rewrite the code following the improved design. In the process I always find new points where further improvements can be made, so you can repeat this exercise several times, getting better designs and improved code each iteration.
  14. Everybody always discusses server applications where the storage backend is a database. This makes it easy to fall in the trap of thinking a database is the only viable storage option for a server application. However, a server application is still an application, so you can also do all the things that 'normal' applications can do (modulo things that would be trivially exploitable from a remote site, as the application reacts on unknown potentially hostile user input). Depending on the application, using a data base for storage may not be the best choice. In my case, I had to load a bunch of translated strings in various languages (around 4000 strings in 50+ languages). Since translators (my users) work on one language rather than on one string, the typical access pattern would be to load many strings of a single language. Actually, "many strings" soon became "all strings", due to providing a list of "related string translations" as a service to the user (hopefully getting more consistent translations). The database solution would be a 'language' table, a 'string-identifier' table (name and description of each string), and a table with the translations, for each language and string. Getting all strings of a language accesses the language table, and then iterates over the strings table, while getting the actual text from the translation table (actual database engines are probably smarter than that though). Not being very happy about that solution, I continued looking for a better solution, and found the alternative to simply store all string-names, descriptions and actual text of one language into 1 file. That makes loading a language as simple as "open file, load the contents straight from the file system, close the file, done!". Given that the database is also stored in a file, My file-based solution is much quicker, since I am not looking for keys, and joining several tables. Writng is quicker too, as it's 1 file creation, and a few rename operations (with a possible remove to delete the oldest version).
  15. Alberth

    Linux IDEs for C++

    "Linux commandline tools" would probably give you starting points, although most hardly scratch the surface or confuse the (bash) shell with tools. There used to be a O'Reilly book "Powertools" that looked useful (except I already knew all the tools it mentioned). I would recommend installing the man-pages, it's an online reference for the various commands, accessed by the "man" command. The man-page about man is "man", ie type "man man" at the console to get help about the man command. All the standard unix commands are documented, eg "man bash" for the manual about the Bash shell. Man-page references are usually written like "bash(1)", which means "man bash in section 1" (the user commands), entered at the console as "man 1 bash". Usually you don't need the section number, except in rare occasions, like write(1) vs write(2) vs write(3) 😛 (write user program, vs write kernel call, vs write C library call). Gnu core utilities manual seems nice too: https://www.gnu.org/software/coreutils/manual/ Edit: Since you're using a lot of GNU software, that site has more documentation you may read at some point. I think that's enough for now
  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!