Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Jan 2013
Offline Last Active Private

#5206528 how to install external libraries on codeblocks

Posted by wintertime on Yesterday, 06:33 AM

The usual cause of errors with SFML is people downloading a precompiled binary for a different compiler than they have installed. You better just compile it yourself with the same compiler you use for your application.

There are tutorials on http://www.sfml-dev.org/tutorials/2.2/ , but they need to be followed exactly.

#5205964 C++ Reflection/Meta System

Posted by wintertime on 22 January 2015 - 04:38 AM

After reading what you wrote I cant help but think you are making the classic mistake of building an overengineered overgeneralized framework, without actually having a use for it. You are forced to look around and ask for more features you should add, because you actually dont need any yourself.

You better first write the user code and only then add missing features to the API, else you would waste your time on making stuff you dont need in a way thats not easily usable by anyone.

#5205140 Can anyone explain why this seems to be the source of intermittent slowdown?

Posted by wintertime on 18 January 2015 - 03:56 PM

Are you uploading all data evertime you want to draw an object? Dont.

The point of a VBO is to upload once (preferably on load time) into one or many of them, and then only draw.

#5204170 OpenGL framebuffer management

Posted by wintertime on 14 January 2015 - 04:06 AM

Back then, when I started with C I somehow prefered postfix, I guess cause of some book I read where people used it out of habit.

When switching to C++ and learning about operator overloading it was advised to use prefix cause it prevents useless copies sometimes and is always at least as efficient as postfix.

But the real reason I mostly use prefix is that having a consistent rule of thumb safes programming time and is easier to read than randomly using both. If I see a postfix I know immediately I used it out of a real need.

Its also more consistent with other operators like *, &, +, -, ~, !. Everytime you don't have a combination of prefix and postfix operators in a statement it could conserve a split second of code reading time.

#5203508 About computer instruction in relation to RAM consumption

Posted by wintertime on 11 January 2015 - 11:42 AM

Actually, I think you are not alone and many people got confused by those many threads asking for things without immediate applicability or basic prior research before opening even more threads. People on here are just too polite or maybe feel it did not rise to a level where they should speak up, but with the months passing and no change...

#5202067 GameState, is this a good practice?

Posted by wintertime on 05 January 2015 - 03:14 PM

I feel you better first learn the programming and its quirks, that will help you more than trying to find the best object oriented design.

- If you provide a "{}" block for the function you dont put ";".

- Never add a destructor if you dont provide copy and move constructors and operator= (follow rule of zero, three or five).

- Follow Dont Repeat Yourself principle. If you feel the need to add numbers to variable names use an array. If you need to repeatedly add the same data, use a loop over the array.

- Delete those useless comments you clutter the code with, anyone can see from the code what a constructor is or that getTitle gets the title. Learn to add useful comments about the big picture goal and why you choose to do something.

#5201112 MMO Terminology

Posted by wintertime on 01 January 2015 - 05:30 AM

Shard stems from Ultima Online, where the roleplay explanation for having multiple servers, with many worlds starting from same state, was along the lines that someone carelessly destroyed the world crystal and it splintered into many shards with mirrored copies, which henceforth could diverge. And the Origin motto used to be "We create worlds"; that word is used for ages already to describe a whole game universe.

Zone or map got often used in Ragnorök Online, where between each of those were warps (glowing, bubbling magic teleporters providing a roleplay explanation and a visual cue). Most warps would teleport you onto another map, but depending on server allocation this could be on the same or another zone-server, as there are over 100 maps and maybe 6 to 20 zone servers. People would just speak of servers, but never call them shard there.

The other words are probably from some other MMO, as each game often had its own vocabulary.

#5200973 Void Pointers - Traversing and Copying

Posted by wintertime on 31 December 2014 - 07:25 AM

If you want to stay standards-compliant there is no pragma to rely on, so you can't use structs for sending/receiving something. Pointer casts and even the union-hack can lead to endian problems or undefined behaviour.

Just treat the packet as a byte-array (uint8_t*) and manually encode/reconstruct all other primitive data types using byte-writes/reads, shifts and memcopy (that also avoids alignment problems). You need to know exactly how it is packed and if its in network byte order and if its in twos-complement form for negative numbers and if its in a compatible float encoding.

#5200972 Bizarre 60x slowdown with DSP filter

Posted by wintertime on 31 December 2014 - 07:06 AM

You should read https://randomascii.wordpress.com/2012/05/20/thats-not-normalthe-performance-of-odd-floats/ . There are even more posts about floats and their pitfalls.

#5200748 What's wrong?

Posted by wintertime on 30 December 2014 - 05:24 AM

I have to do a programming excercise for university.
I've done most of it, but I get some error and I can't figure out what's
wrong and how to solve it.
I hope you can understand it, because as I said it's for university and 
that's why I have to do it in my native language.


Why do other people need to decipher a foreign language to debug your intentionally contrived homework, that you are supposed to do yourself to presumably learn those things by doing them?huh.png

At http://en.cppreference.com/w/cpp/language you can read almost anything about C++, happy learning.wink.png

#5200405 C++ : multiple inheritance & casting

Posted by wintertime on 28 December 2014 - 06:24 AM

Thats a typical, but bad idea. The rigid inheritance structure will give you problems when you need one aspect of a class without another thats already inherited, causing code duplication or bloated objects or objects with deactivated parts.
You better just have independent components like Position, BoundingBox, Mesh for graphics and others with data for the game logic. Then you can combine these as needed through composition into game objects or just have some arrays of these components, depending on your needs.

#5199078 AI in 4X

Posted by wintertime on 19 December 2014 - 05:06 AM

This is not as new as you think, I read an article some time ago (sorry, dont remember where), where someone proposed using a hierarchical AI to make it easier to program and more life-like.
I think its a good idea to do it that way. The way you partitioned it, I'm not so sure about.
It seems you wanted to split it in a way to have some parts do a only single simplistic decision function; I would start with the responsibilities in a life-like structure and modeling this, like in your last posting.
I would gather information about needs and offers from bottom up first, let next higher levels summarize to reduce irrelevant details. Only when everyone is informed give orders from top down for the group of "people" on next lower level remembering the details to implement for their subsection. This way would cut down on circular back and forth where the higher level decides something without knowing and the lower then tells its impossible or does not apply to current situation.

#5198771 constructor for class that contains another class and constructor C++

Posted by wintertime on 17 December 2014 - 09:16 AM

I personally dont like having vector classes derive from each other in that way. A 4D vector is not a 3D vector, its more like the 3D vector is a special case of the 4D vector.
Its easy to add a conversion constructor for cases where you really want conversion without needing inheritance and prevents loosing w silently.
Additionally, the natural form of a vector is IMO an array, not a struct. This allows indexing and cuts down on repetition from having getX, getY, getZ, getW, getU, getV, getR, getG, getB, getA, ...

Btw., why dont you use a premade library like glm or others?

#5198201 C++: Easiest way to implement an in-game Time/Date system?...

Posted by wintertime on 14 December 2014 - 04:22 PM

As for converting to milliseconds etc...
I currently add the time difference to a boost::posix_time::ptime object in milliseconds, so my function for getting ticks looks like this:

	QueryPerformanceCounter( &count );

	QueryPerformanceFrequency( &freq );

	return ( LONGLONG( 1000 ) * count.QuadPart )/freq.QuadPart;
Then I add the result of the difference between 2 readings, multiplied by interpolation, to the displayed time. There's nothing wrong with that, is there?

That is so wrong. The multiplication could overflow and you are wasting precision by converting too early.
Always keep the ticks as long as possible, subtract 2 tick values to get the time difference, then only on last moment before using the value for drawing convert it to milliseconds.

#5198102 30k concurrent players on a (private) MMO server...is this possible ?

Posted by wintertime on 14 December 2014 - 04:57 AM

In Ragnarök Online ground, walls, houses, trees and such are actually made of 3D. There are many hills (which are a good reason to prefer 3D), its relatively low-poly and you can sometimes find cracks revealing it.
Just the camera is rather restrictively fixed and you can only be rotated around your character, zoom a bit and change its angle slightly (that is one of the many things I heared some cheaters have hex-edited away). This is to hide that the server only sends data for characters and skill effects inside a square for about 14 tiles distance from your character (which can be seen when tilting the camera and looking downhill or having a widescreen monitor).
Monster, NPC, Characters and their accessories are 2D sprites though.
I've seen fights of 2-3 allys of 2-4 guilds per ally of 30-56 people each guild, all squeezed into 2 or 3 screens of space. Problems start when all are spamming skills up to 4 times a second (they made the mistake of including a 2 minute area spell reducing cast times and skill delays for everyone inside), which are often area spells that get send per tile. Then the server is struggling, its discarding skill effects revealing holes, discarding skill commands, queuing move clicks for too long and ultimately disconnecting everyone lagged more than a minute, sometimes silently making the client hang, all while the monsters whack away at the player characters.
Additionally, rumours are going around the server is not optimized well.

Therefore more than 16-32 people per map should certainly be possible for your game if done carefully enough.