Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About antiquechrono

  • Rank
  1. antiquechrono

    Multithreading problem - Win32

    In response to the original question, correct me if I am wrong, but isn't the OP asking about the readers writers problem? Quote:Operating System Concepts 7th Edition A database is to be shared among several concurrent processes. Some of these processes may want only to read the database, whereas others may want to update (that is, to read and write) the database. We distinguish between these two types of processes by referring to the former as readers and to the latter as writers. Obviously, if two readers access the shared data simultaneously, no adverse affects will result. However, if a writer and some other thread ( either a reader or a writer) access the database simultaneously, chaos may ensue. it goes on to provide a pseudocode solution semaphore mutex, wrt; int readcount; //writer solution do{ wait(wrt); ... //writing is performed ... signal(wrt); }while(true); //reader solution do{ wait(mutex); readcount++; if(readcount == 1) wait(wrt); signal(mutex); ... //reading is performed ... wait(mutex); readcount--; if(readcount == 0) signal(wrt); signal(mutex); }while(true); Do note that this solution can cause starvation for the writers
  2. antiquechrono

    [C++] Save and load system

    Post what is acctually being written to the file. If I were to guess though you are writing integers and strings to the file and probobly without spaces inbetween. When you try to read it back in it does not know what to do because it is a big mess of numbers and characters.
  3. antiquechrono

    Problem with reference variables

    Quote:Original post by ForeverNoobie Well, I guess I wanted the class to be able to be used for more things than just 2d and 3d boxes. I wanted the class to be able to possibly hold more than 6 elements and I figured being able to iterate through the elements would make certain algorithms easier. I wanted reference code names for a bit of simplicity in the case that the class was being used to represent a box. I think this is a case of over zealous design. A box should behave like a box, and an elephant should behave like an elephant. I don't think you would want to design a boxephant, however in the event that you want to be a mad scientist you could use multiple inheritance, but that probobly is not a good idea either.
  4. antiquechrono

    C++ and Random access files

    By default the fstream objects can do sequential and random access to files here is a short tutorial with samples http://www.difranco.net/cop2334/Outlines/fileproc.htm
  5. antiquechrono

    VC++ 2008 Express Debugger

    Introduction to Debugging
  6. antiquechrono

    Fundamental Pointer Problems - C++

    Since this is turning into a back and forth argument I am going to yield to those of greater experience. I really would like resources to the topics discussed like Mike.Popoloski asked about though as it would help me learn about all the things I obviously have no clue about since three years of college has obviously gotten me nowhere. My professor who acctually worked "in industry" directly stated that no one who writes professional code "in industry" uses the STL and all the companies rewrite it and even had us do all our projects without it. So I'm sorry if I offended anyone.
  7. antiquechrono

    Fundamental Pointer Problems - C++

    Quote:Original post by EasilyConfused So by your "logic", I guess we should be advising beginners on this forum to learn assembly language before C then? Well you are kind of responsible for starting the thread hijack into code and compiler optimization, I suppose that is a beginners topic as well? Quote:Original post by EasilyConfused I'd be interested to see some profiling code that supports any of these claims. Hundreds of times faster? Like I said, If you are curious then write it and run some tests. I'm just speaking from limited but practical experience. I wrote an RSS feed parser which is obviously heavily text based. I ran callgrind on it and most of my code without surprise was spent manipulating strings thus the reason I wrote my char array based string class which ran circles around the standard string for my purposes. Quote:Original post by rip-off Array based? Do you mean an arbitrary upper limit character array? That is comparing apples to oranges. No, I said an array based string. A class that has a dynamically allocated array. Quote:Original post by ToohrVyk A computer does not work 'like pointers'. Pointers have no representation of segmented memory or virtual memory layouts, and low-level memory has no concept of type or stride. Someone who lives with the illusion that the C or C++ operational semantics are somehow representative of computer architectures from the last decade is someone who is not going to be hired. I'm not sure if you are doing quantum computing or something, but last I checked the most basic functionality of a processor is to fetch instructions from an address and execute them and in the process more than likely manipulate data which is at another address. It has no concept of a variable, just an addresses to data. Now call me old fashioned but that sounds an awful lot like what a pointer is. Quote:Original post by ToohrVyk Now, this is downright stupid. Global replacement of one methodology with another (such as replacing all standard library code with your own) is not optimization, it's voodoo. Optimization consists in writing some working code as quickly as possible (which will involve using the standard library in almost every single case), and only then optimizing your code based on profiling data. Once you have access to profiling data incriminating standard library code for significant performance losses, you can do the local replacement. Reinventing standard library functionality without profiling data will result in almost every single case in spending dozens of man-hours, worsening code quality, and not achieving any observable result on the user side because you made ten times faster a portion of code which costs you a mere ten milliseconds per day. Yes I realize this and the way I said it came out very wrong. You never optimize until the end of a project. And I never meant to suggest that you should just globally toss out the standard libraries. But, then again what is the point in debating how in the world a compiler is going to optimize your code for you? Quote:Original post by ToohrVyk Smart pointers (including boost::shared_ptr, and boost::optional references) and references are enough for 99% of cases. The cases not covered involve mostly pointer arithmetic, string literals and C function interaction, all of which should be cleanly tight-wrapped away from your actual C++ code anyway. Unlike C, programming in C++ is best done without naked pointers. This is an interesting idea, but how come I never see any smart pointers used in acctual code or examples? My professors certainly have never even mentioned smart pointers before, do you have any resources I can look at discussing this because I have just been taught that *ptr is the way to go. Quote:Original post by rip-off Most of the things that you "cannot accomplish without pointers" have been implemented for you in the Standard C++ Library or Boost. Remember, this was posted in "For Beginners". Keep that in mind. Ever write a custom data structure before? Quote:Original post by rip-off In any case, I would value a programmer who only understands C++ pretty much the same as one who only knows Java. A good programmer is usually fluent in many languages. The problem with Java is that there is really nothing inheriently hard in the language because everything is abstracted away. It may be easyer to learn but how much do you acctually understand if all you know is how to write Java code using the wonderful library where everything is written for you? I'm not bashing Java though it is a great language.
  8. antiquechrono

    Fundamental Pointer Problems - C++

    Quote:Original post by EasilyConfused However, all of the above are typical examples of the potential problems with using pointers directly in C++ and why you should almost always prefer to use standard library containers or smart pointers instead. std::vector<int> f() { return std::vector<int>(200); } void g() { std::vector<int> v=f(); // do stuff } The above is very hard to break, and is unlikely to have any significant performance penalties. Even the apparent additional copy of the vector when being returned is likely to be optimised away by the compiler. I just wanted to point out the nonsense in this post for any confused third parties. First of all...never use pointers? I scoff at that remark they are one of the reasons C and C++ are so powerful, without pointers there are tons of things you can not accomplish. Without an understanding of lower level ideas such as pointers you are missing out on how the computer acctually works, which is why people who only understand the higher level languages like Java can be passed up for jobs. Always prefer standard library containers or smart pointers instead? Again no, the standard smart pointer that comes with C++ can be a pain to use and is not adequate for some cases. Also, the STL is painfully slow and unoptimized, it seems to be a myth that it is some sort of super fast uber optimized library programmed by God himself. It was not written to be fast, it was written to be portable. In any serious programming project you need to avoid these things like the black plague if you care at all about speed. If you still do not believe me just write out your own array based string class, for most of the generic string operations it will be hundreds of times faster than the standard string.
  9. antiquechrono

    Game assets in an online world

    Since you aren't too worried about it there are a couple of relatively easy things you could do with your files. In the end though if someone really wanted to get to the data then they could. 1. Just rename the file extension of your zip files to whatever you want like a .stf for stormtrooper format lol, this will keep the computer illiterate out of your assets which by and far is most people. 2. Encrypt all of your files, this has the downside that when you load anything you are going to have to spend the time to decrypt the file. 3. Create your own binary file format! 4. Speaking of Quake I belive there are acctually tools out there for creating your own .pak files if you want. Thats just off the top of my head and I'm not the most qualified person to answer your question. I do believe that the first suggestion will keep most people from snooping though.
  10. antiquechrono

    Fundamental Pointer Problems - C++

    Because the pointers are local variables in the functions you are writing. In example when you call MapGen() it creates all the variables does whatever it does with them, and then when the function is done they are all destroyed.
  11. antiquechrono

    OO help

    Quote:Original post by jagguy2 ok i see your point, and thaks for the article. I did change my globals and by the looks of it if i have a directx class(for initialization and variables) then that may solve the problem. q1)What i did try and I since changed was that i had global variables of the same name in 2 .cpp files and i got a linker error. I take it you cant do this? q2)what about all the win32 initialization code i was wondering what to do with this eg make it a class, namespace,.h file? 1) No you can not because if the two files are included in such a way that you get a name confilct then the linker will not know which variable to use. Which leads to another reason not to use globals, you run out of useful names lol. 2) Try this Win32 template I found, adapt anything you do not like http://users.ece.gatech.edu/~lanterma/mpg/direct3dbasics_code.zip
  12. antiquechrono

    Just getting started

    I am going to say that you can not go wrong with SDL, it is easy to use and has been ported to every major OS, someone even got it working on the Sony PSP lol. http://www.libsdl.org
  13. antiquechrono

    Rotate Sprite

    Try this http://www.toymaker.info/Games/html/sprites.html
  14. antiquechrono

    ostringstream going wrong - c++

    Quote:Original post by jyk However, IMO the 'void' thing really isn't splitting hairs, and it's not equivalent to issues such as, say, bracket placement. In C++, putting 'void' in parentheses to indicate an empty argument list just adds visual and conceptual noise to the code. There is no benefit, and it could be argued that there is a loss of clarity. So I think 'just don't do it' is reasonable advice here. I can see where you are going with this. For instance my friend uses the "this" pointer on every single variable in all of his classes and it drives me absolutely crazy. I finally got a good laugh when it came back to bite him when he had a nasty bug that turned out to be due to dereferenceing one of them wrong.
  15. antiquechrono

    ostringstream going wrong - c++

    Quote:Original post by jcullet Well, in C, writing foo(void) explicitly tells the compiler that a function must be called with no arguments. Thus calling foo(1,2) would give a compile time error. At the same time, declaring foo() in C will allow you to call foo(1,2) without a compiler error. C++ treats both declarations the same. That is, foo(void) and foo() are equivalent and each will raise a compiler error if you try to call foo(1,2). It is simply unnecessary to write foo(void) in C++. You are really splitting hairs here, just because it is unessecary means you can not do it and is wrong? I most certainly think not. That is almost as silly as people arguing over whether a brace goes on the same line as the difinition of a function or not. Unless you have a real code breaking reason for someone not to do something then do not go around telling others to change thier coding styles. That is up to what the individual wants to do or what their professor/boss tells them. To the original poster, whatever you decided to do just be consistant with it.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!