xtrmntr

Members
  • Content count

    243
  • Joined

  • Last visited

Community Reputation

144 Neutral

About xtrmntr

  • Rank
    Member
  1. 2D sprites rotation...

    You can download a small tutorial which takes the 2d rotation algorithm from Tricks of the Game Programming Guru's and attempts to speed it up: http://www.programmersheaven.com/zone10/cat345/15441.htm I haven't tried it out, so I'm not sure about its performance.
  2. I'll assume you are refering to RPG/MMORPG's since most games don't involve the need for money to acquire stuff. Can you give me a definition of a society where money doesn't exist? I'm not a Star Trek fan so I don't understand the reference. Is it a barter society where items/goods are traded for other goods? I would assume that these types of things don't just materialize or that the person who owns them would willingly give them to you. I suppose making a system where, instead of exploded gold pinata monsters, the monsters are exploding goods pinata's. To aquire more unique items may require that you find some set of goods which can be traded for that cool new dagger. It still results in the same type of system though. Perhaps limit the player to only gain access to items/potions/weapons through crafting. The biggest problem is making crafting fun. I have yet to experienced a crafting system that I would define as fun.
  3. That's even cooler! :) rating++;
  4. The file consists of lines of the format: number tab string. wstringstream was the closest thing to a tokenizer that I could find in the STL. Instead of doing: getline(file, myString, L'\u0009'); int number = _wtoi(myString.c_str()); getline(file, myString, L'\u2028'); I can just do: stringStream >> number >> std::ws >> myString; At the very least, it looks nicer. Plus there will be other files formatted differently than this one. On a side note: - Is there some good reason why file.close() does NOT clear the file streams state? What else would someone do with a closed file stream except open up another file or wait for the variable to be destroyed?
  5. Fruny: I'm using the codecvt<> defined by P. J. Plaugher ([url]http://groups-beta.google.com/group/comp.std.c++/msg/960feb01524a8f2d?hl=en&lr=&ie=UTF-8&oe=UTF-8[/url]) which allows you to actually read 2-byte characters instead of having it read 1-byte and pad it with 0. If there is a built-in one I would love to know about it. Turning off stdio syncing made: wifstream file("text.txt"); wchar_t * buf = new wchar_t[fileSize]; file.read(buf, fileSize); work much faster. My assumption is that when I do something like: wifstream file("text.txt"); wstringstream s; s << file.rdbuf(); the speed hit _may_ be due to buffer reallocation? (a bit of a stretch though) Thanks for the help guys!
  6. Hopefully I am doing something drastically wrong here, or perhaps this is normal. I am trying to read from a file using a wifstream (it's a UTF-16 encoded file). The file contains roughly 24000 lines of text where the text is ~length of 6 wchar_t's each. When performing the following statements, it takes about 2-3 seconds (by my observation) to complete: I have tried: wifstream file("text.txt"); wstringstream buffer; buffer << file.rdbuf(); And: wifstream file("text.txt"); wchar_t * buf = new wchar_t[fileSize]; file.read(buf, fileSize); At first I thought it was due to the fileSize but thought "what the heck" and tried fopen: FILE* f; wchar_t * buf = new wchar_t[fileSize]; f = fopen("text.txt", "rb"); fread(buf, fileSize, 2, f); I found that fopen reads in the entire file without any delays whatsoever(?!?!). Anybody have a clue as to why I may be seeing such a huge degrade in performance using fstream?
  7. @frob: Thanks for your suggestions. The use of pipes is how it is currently being done but I was hoping for a nicer looking solution. What I also wanted to achieve was to make it as platform independent as possible... oh well :) @magmai: Reading through The Standard C++ Library by Nicolai Josuttis, he shows how you can use tie() to connect std::cout to an ofstream which seemed like what I wanted. Unfortunately, there seems to be no way for me to retrieve a different processes std::cout with which to tie() it to. Agreed, it would be nice to have a socketbuf to attach to an fstream. Might be a worthwhile project for myself to explorer tcp and how to define custom streambuf's. What I finally ended up doing was taking advantage of the fact that I have cygwin installed and do something like: D:\myperl.pl 1>targetfile.bin 2>error.log. Perhaps not the greatest solution but preferable (imo) to dealing with windows pipes.
  8. Ok, so here's what I'm trying to accomplish: Attach an std::ofstream created in my running app to the stdout of a process launched from my app. I've searched around google.com and have only found ways to do this via Win32 HANDLE's. As far as I know, STL fstreams don't support file descriptors (although I read that they used to or at least some implementations do/used to) so it looks like going that route is out of the question. Also, fstream's tie() method works only with ostreams which doesn't help me (or does it?). Has anybody ever done this or maybe has some useful input about my problem?
  9. I'm just finishing up a combo training class offered by Microsoft which includes programming in C# and the .NET framework + windows forms and I must say, I am quite impressed with it. Having programmed for ~3 years in MFC, WinForms and the other utilities provided by the .NET Framework are a very much welcomed alternative. VS.NET provides such great support for automating development that it's almost as dumbed down as you would want it to be. One of the features that really stood out for me was language interop. This gives development of tools the best of both worlds, code written in the software's native language hooked up to a framework that makes GUI developmenta breeze.
  10. Like Sta7ic mentioned in his post, I think it would be cool to add the element of elections. If the current leadership has been killed off or dies or maybe even "retired" you could signal that your town/city/kingdom requires new leadership. Give the inhabitants (either strictly human or both human and NPC) of this place a set of people which they can elect. These people may be of different class type. For instance, the old leadership was a heavy duty fighter type and one of the running mates is a mage or a ranger to help steer a new direction for the town. It could invite new types of NPC's to appear in a town. This shift in leadership would effectively cycle a new population. If some of the human inhabitants aren't happy with the elected person than they move to a different place causing bitter rivalry's. There's a lot more you _could_ do with this type of system if it is indeed possible to implement well. just my 2 cents.
  11. It's alive

    http://www.napa.ufl.edu/2004news/braindish.htm Not sure if anyone has seen this yet but I was personally amazed by it. What are peoples view's of applications, is this "right" or is it just a bunch of crap?
  12. What were the desired results you were looking for in fstreams?
  13. Why do people still use C ?

    Being an embedded developer I have written software targetted for in both C and most recently C++. We are updating our flagship product (iTAP) using C++ and have already run into problems with it. Embedded devices use a range of different types of hardware, all of which will need to have a compiler with which to build programs for them. There are no gaurantees that the features you use will be supported by all of these compilers so you need to use a minimal set of them. For instance, namespaces. We started using namespaces to encapsulate our library and wouldn't you know it... namespaces supported for compiler A but not compiler B :(. We then tried to use templates.. phew, templates are supported on our current set of compilers. The problem is, even though templates are supported on the compilers our existing customers use doesn't mean that it has to be supported on a different compiler used by a new customer. If this is the case, it would cost us money which is always a bad thing so we need to consider not using this feature as well. We continue to use C++ but we watch what features we use and everything seems to be alright. There has been a definite improvement in readability as well as flexibility with using C++. As far as speed goes, I can't really tell the difference. Our program actually runs faster than the previous version which was written in C but that can't really be used as a comparison due to the fact that some of the logic has changed. Just to iterate what some people have already said, people use C for portability especially when writing for embedded platforms.
  14. Awesome! I guess I was just not using it correctly when I tried switching to this safer way of doing it. Suppose I have been lucky that the memcpy way worked on the variety of compilers that I built my library for (ARM, MCORE, Infineon, etc). Thanks :)
  15. Sneftl, So you are saying I can define the following function in my class without any needed headers? class MyClass { public: static void* operator new(size_t s, void* mem) { return mem; } } then inside my library function call do MyClass * p = new(heapBlock.memory) MyClass(); ? edit: The reason I ask this is that while looking for placement new stuff on the forum I came across a post saying that this type of placement new did not work on GCC unless you include the <new> header file. This is one of my restrictions.