Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    8
  • comments
    10
  • views
    9602

Entries in this blog

 

Just got home

I just came home from my aunt, where we celebrated christmas (in Denmark we celebrate christmas and get presents in the evening of the 24th). I got the following presents:


Raptor ATA HD, 36,7GB, 10000RPM
King Kong, collectors edition (PS2)
Star Wars Battlefront 2(PS2)
The two last books in a triology.
~$65 gift token (right word? Looked it up in a dictonary) for a store which sells music, and computer stuff (at 3x the price on the Internet).
~$37


I knew I was getting the HD from my mother and father, I will install it tommorow. In one of the other journal posts I said I didn't like King Kong (for the PC), but thinking about it I actually think the reason was that it was designed for consoles, and the PC port was not well done because they had to release it before christmas, and at the same time as the movie. For example the controls where very simple and they could have used the keyboard much better, but on a console you don't have that many buttons so there it might be a good way to control it. I don't think Battlefront is anything special, tried it at a friend, but I weren't impressed.

I also knew I was getting the books because my mother had to ask me if I wanted them, but it was hard without telling me why, she tried, but it was not hard to guess. Money and gift tokens where just from people who didn't know what to get me. I also got Starwars III, but I already have it, but I didn't mention it because I already have it and the people who gave it to me just bought it because they HAD to (since everyone else gave presents), I really don't see the reason that they even used those 5 minutes (and money) getting me a present.

I actually got better presents than I had expected, also the "ceremony" (or whatever it's called) went very well, it was fun and we had some good food.

Of the presents I gave I think the only one who really liked it, was my little sister, I got her some toy where you connect small magnets, there is also some iron balls, you can then make lots of stuff, kind of like Lego (well actually not, but it's the closest thing I know of), I don't know if anyone know what I'm talking about, they are called GeoMag here in Denmark. I also think my father liked his present, a special calendar with stuff about the nature (almost $40), my mother didn't seem to excited about her present though, but I didn't really knew what to give her either (of course she said thanks, and that she liked it). And none of the other family members seemed to care, since I generally give less than the adults.

CTar

CTar

 

Impressed with python

I just started learning Python (knew the basics before, but forgot them), one thing I'm impressed with is the large values, I mean I just tried computing !20000 and it did without an error, you would need some custom data type in C++. Also it is so much easier to understand, one thing which annoys me though is the : after functions, if, elif, else, while and probably also the other loops and classes, but I haven't read about that yet.

Anyway I just wanted to say it is very easy to code, and the code is clean, 2 months ago I tried LISP (well AutoLISP, but probably the same syntax) and it looked like brainfuck, it just replaced half of the instructions with a combination of parantheses and it allowed variables.

CTar

CTar

 

Newer games lacking quality?

I have noticed that the last three games I played was filled with bugs and not very fun, I'm not that much of a gamer so I have to ask is this something happening to almost all new games or have I just been unlucky. I mean, I bought King Kong for PC and it was just as much a disappointment as I would imagine Big Rigs (for those who don't know about this game, see this review) would be. The first 11-12 (not sure and I don't want to count, the chapter after Canyon) chapters were very boring, it was mostly just a question of running around as Jack shooting worms and other small creatures, there was also one or two levels with Kong, the levels where played something like this (LMB = Left Mouse Button, FWD = Forward):
x10 -> x10 repeat
You where supposed to jump on the side of a mountain, this was very&lt/Sarcasm> hard, especially since you couldn't fall down at ALL. Also when walking around with Jack it was almost impossible to fall down, I think you could when you walked on some wood over a large gap, but not in any other circumstances.

The creators have chosen not to have a HUD, I guess they wanted to be innovative, but please don't use an idea just because it's new. The rules for controlling your health are like this:
- Get hit by anything, could be a TRex or a worm, and then your screen turns red (not completely) for ~10 seconds, after that it turns back.
- If you are hit while your screen is red you die
This could just have been so much easier with a HUD, also you can't see how much ammo you have left, you have to "ask" (I) Jack and he will tell approximately how much is left, if you around 35 bullets he will just tell you that you have enough.

In the chapter after the Canyon a bug made some fire stop and I needed this fire to continue in the game, of course there is no option to restart the chapter, the only thing I can do is to start over (from the very beginning).

It seems that the artists in King Kong where very good, but the coders and designers must either have been very in-experienced or being forced to meet un-reasonable deadlines.

A couple of weeks before that my little sister got a demo of Harry Potter and the Goblet of Fire. Since it was only a demo I can't give a review as long as the one on King Kong, but still it gave me an impression of the game. You start walking around in a camp getting hit by lots of weird particles from the sky; this doesn't do any damage at all even though they look like they could kill a group of 10 people. Then you get the ability to move rocks, just to test if the rock was just as harmless as the particles from the sky I tried dropping the rock (very big rock almost as big as a car) onto the others (you choose between Ron, Hermione and Harry and the other two follow you), but nothing happened then I tried dropping it on myself (Hermione in this case since my little sister started playing) this resulted in me going down under the ground and couldn't move, about 5 seconds later the program shut down. So have lots of problems.

I also got BF2 almost immediately after it was released and as most can remember there where some serious bugs in it. Most was fixed with the patches, but it is not acceptable to release a game in a state like that.

It just seems to me that all newer games are very bad. The last good games I bought were HL2 and B&W2 and all games I bought before that was also not filled with bugs, but it seemed that at some point companies just started releasing unfinished games and hope to release patches later. Also B&W2 wasn't bug-free it was impossible to accomplish a task in 2nd or 3rd (don't remember) world where you had to remove all trees.

CTar

CTar

 

My opinion on the new design.

The new GDNet design has probably affected all here a lot, some might think it's a good thing while others would have preferred the old one.

My opinion on the matter is:
I prefer a white (well just some bright color, might be gray) text on black background, just like it sounds most other people here does. I'm starting to get used to the site since the brightness have been lowered a few times, both on the site and my monitor. So now I don't care that much, I just hope the admins will get a black theme ready in a couple of weeks (don't know how much it takes to make such a theme).

Lots of things apart from the color scheme have of course changed, and I'm very impressed with most of them. The site still looks like it's in some early beta version, but if I'm not very mistaking (don't think there have been an "official" comment on this matter) this is some kind of big beta test with lots of testers.

One thing I hope will be fixed soon is the dropdown menu, which I really hope they will get fixed soon. One of the big problems I had with the old GDNet was that the menu at the top was a mess, after a couple of weeks I knew where most stuff in the menu was, but it looks very bad to first time visitors. The dropdown menu made a very big improvement to the "ease of navigation".

Another thing I really like is the new source code boxes, I don't know what it's, but they just look much better. It might be because the background aren't going from something like 0, 0, 0 to 255,255,255 (with 255 max, in RGB format), but more like 200, 200, 200 to 255, 255, 255.

I also like the way if any new messages is in a forum is indicated (red ball / bright blue ball). It is much easier to spot the difference.

So for a conclusion:
I think the new design, with some time, will far surpass the old one, especially in usability and eye-candy (yes, admit it, it does matter.

CTar

CTar

 

const char* to bool, not std::string(bug)

I found a very strange bug in some of my code the other day, I isolated the problem to this:


#include
#include

void Print(bool P)
{
std::cout }
void Print(const std::string& P)
{
std::cout }

int main()
{
Print("test\n");
const std::string Tmp = "test\n";
Print(Tmp);

return 0;
}



What do you think this will output? I thought the output would be:

test
test


But the output (in both VC7.1 and VC8.0) is:


1test


In VS2005 the code compiles without a single error on the highest warning level (4). I did some debugging and figured out the bool overload was called with the first function call, and the std::string overload was called with the second function call. First when I tried to code in VS2003 I found the error, I got the warning:

\Main.cpp(15) : warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)

Then it quickly became clear that I was passing a const char*, I thought it would be converted to a std::string, but since a const char* is just a pointer it was converted to a boolean, true in this case because the address wasn't 0.

I fixed it by adding an overload taking const char*. So this is what happens when you think of const char* as a string, not a pointer and when you assume "test" is more likely to be converted to a string than a boolean value.

CTar

CTar

 

Refactoring is evil

Five days ago I chose to refactor my file system, since it was actually only a prototype, and it would be a PITA to make any changes to later.

Now, five days after I started refactoring, I have finally gotten my code to compile once again. At one point I had 4000 lines of code(not including comments, whitespace etc.), it was some recursive template stuff. I'm a little disappointed since before refactoring I had over 3500 LOC(lines of code), now I only have 2865 LOC[crying] which doesn't sound as good, I had hoped I would cross the 5000 LOC barrier sometime next week, but that isn't going to happen because I had to refactor even though I haven't gained any new functionality.

I had actually planned to refactor my logging system too, but I think I will work on a memory manager first since I don't want to drop below 2500 LOC.

Everything was much easier when I was just learning C++ and just added code to my main function without ever removing a single line. Also copy-pasting instead of creating general-purpose functions could helped a lot to "improve" the number of LOC.

Well everything isn't bad, I have just gotten Introduction to algorithms, 2nd edition which I hope is a good book. It will probably give me even less time to work on my engine, but it will probably pay off later when I choose the right algorithms and don't have to spend weaks optimizing the wrong sort algorithm.

CTar

CTar

 

A flexible file system

As you can see in my last journal post I have just started this journal, so I wanted to post something fast, so I have created a little post about the file system I use in my game engine.

Requirements
What do we need in a file system? We need support for opening, closing, reading and writing to files in both binary and text mode, we also need to be able to navigate a tree of directories and want the user to be able to add support for additional "file systems" like tar.gz files if (s)he want to. We also want as much as possible from the user.

Implementation
In the requirements we said we needed to let the user add functionality, we will accomplish this with interfaces. For example we have a binary input file, its interface is:


namespace FileSystem
{
class iBinaryIFile
{
public:
typedef std::streamsize StreamSize;

iBinaryIFile(){}
virtual ~iBinaryIFile(){}
virtual ErrorCode Open(const String& pFilename) = 0;
virtual void Close() = 0;

virtual void Read(Byte* pData,StreamSize pSize) = 0;
templatetypename T>
void Read(T& pData)
{
assert( IsOpen() );
assert( sizeof(T) sizeof(StreamSize) );
Read(&pData,static_cast(sizeof(T)) );
}
virtual Boolean IsOpen()const = 0;
virtual String Filename() const = 0;
};
}



Then if the user want to add functionality for some file system or even their custom ones they can just derive a new class from this interface. We still need a way to navigate the file system. This file system "library" will assume that the file system are navigated through a tree of directories, with n files and m directories in each directory. Just like most file systems today. If a file system doesn't support directories it can just emulate directories, for example if it is instructed to create a file in directory(/ seperates directories) "Test1/Test2/Test3/file.dat" it can just save the file with a name like this:
"Test1_Test2_Test3_file.dat"
One problem could be that this file:
"Test1/Test2/Test3_file.dat"
Would have the same name, so if we want to be sure not to encounter name collisions we could just replace _ with __. So a name will be transformed like this:

"Test1_Test2/Test3/Test4__Test5/Test6.da_t" // Original
"Test1__Test2/Test3/Test4____Test5/Test6.da__t" // Replace('_',"__")
"Test1__Test2_Test3_Test4____Test5_Test6.da__t" // Replace('/','_')

Then name collisions are impossible.

Of course we also need an interface for directories, so we add an iDirectory like this:


namespace FileSystem
{
class iDirectory
{
public:
iDirectory(){}
virtual ~iDirectory(){}

// Note: ".." to go one back
virtual bool OpenDirectory(const String& pName) = 0;

virtual std::string ToStr() = 0;
};
}



This interface needs lots of extra functionality, but let's discuss this first. We have OpenDirectory which open a sub-directory, just like the cd(change directory) command. The ToStr returns the current directory as a string.

We now have a very big problem which is that we can't get any info about what is in the directory. Here I have chosen to go with an iterator approach, so we have an iterator which traverses through all elements (both files and directories) in the directory.

One problem though is that we have four file types:

iBinaryIFile
iTextIFile
iBinaryOFile
iTextOFile

And all of them require us to actually open the file which would be way too slow; also they wouldn't work for directories. I guess I could do something like this:


// I don't remember if that is the correct syntax for unions, but you get the idea
union
{
iBinaryIFile BIFile;
iTextIFile TIFile;
iBinaryOFile BOFile;
iTextOFile TOFile;
std::string DirectoryName;
};



Instead I have chosen to create a new type:


iFile // can also represent directories


All it have is a filename (string) and a boolean variable telling whether it is a file or a directory. Then it contains the following pure-virtual functions:

virtual boost::shared_ptr OpenBinaryOutputFile(
Boolean pAppend = false)const = 0;
virtual boost::shared_ptr OpenTextOutputFile(
Boolean pAppend = false)const = 0;
virtual boost::shared_ptr OpenBinaryInputFile()const = 0;
virtual boost::shared_ptr OpenTextInputFile()const = 0;



When we do it this way we can also hide the details of the classes derived from i[Binary|Text][O|I]File since only the definitions of Open[Binary|Text][Output|Input]File will create the file and the user's code will just use pointers to the interfaces.

We will of course not use iFile as the iterator, since it isn't an iterator. Instead we will have an iterator and let the dereference operator(*) return an iFile object.

One important part of the iDirectory class is also that it can open files like iFile, it just have to supply the filename. This is for performance reasons, imagine we have all our resources in a single file Res.cfs (cfs = custom file system) This file uses our custom file system and might contain 2500 different files so we would have to iterate through, on average, 1250 files before we could open the resource we were looking for.

Conclusion
I hope this gave you a good idea of how I have designed my file system, if you have any questions or suggestions just post a comment here or send me a PM.

CTar

CTar

 

Got GDNet+

I just subscribed to GDNet+ and thought I would start posting in my journal. In this journal I will mostly post my thoughts on various subjects like RTTI, and also describe my ideas for various things like how a logging system should be designed. I also need to get an avatar soon.

CTar

CTar

Sign in to follow this  
  • 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!