vovansim

Members
  • Content count

    207
  • Joined

  • Last visited

Community Reputation

336 Neutral

About vovansim

  • Rank
    Member
  1. [.net] Playing Many Videos

    joelmartinez, I have worked on a similar project, although it was different in that we were limited to about four or five videos, but it was to run on a mobile device. Now, you say you would run this on a top of the line computer, so of course you have far far more hardware to work with, yet I think 60 videos is a goal ambitious enough to where you might run into the same kind of problem as I did. Something I ran into pretty much right off the bat was the fact that actually rendering the videos is the easy bit. ;) What takes a lot of time is decoding the video from the file, so I would suggest dedicating some time to research in this area. (Google seems to have plenty of answers for the kind of stats you would need.) Of course the videos would necessarily be pretty small. 60 videos at a time means about a 8 x 8 grid of pictures, so on 1600 x 1200 monitor, that would be the picture size roughly of 160 x 120, if you want them on screen all at the same time. That's pretty tiny, and if the original video you are reading from is that resolution, then maybe decoding won't be that bad. You'd need to run some tests I guess. Also, taking in all those videos all at the same time might be a bit hard. I am no HCI expert, but I would *guess* when you are looking at a grid that big, you probably can't see more than the 3x3 pictures around the point you are looking at. So maybe one curious experiment to run would be to track mouse motion, and only play the 9 videos in a square around the one the mouse is pointing at. Then, the user would follow where he's looking with the mouse, and only the videos he can take in at a time will be playing - the others would just be still images. That might look pretty cool. Of course, then, it might look like ass. ;)
  2. Thanks for the suggestions, guys. Basically what y'all are saying boils down to writing my own simplified parser. That's an option, of course, albeit not one I am altogether comfortable with. Thanks for the feedback any way.
  3. The situation, in a nutshell, is as follows. I have a third-party application (not written in .NET) that I need to write a certain tool for (which I am writing in .NET). In order to do this, I need to be able to parse the application's log file. So, what I need is hopefully a simple, but reasonably flexible, and hopefully efficient way to parse the log file. Now, obviously, the log file is generated by the program, so there is a limited number of possible message formats. That's good. However, the number of different message types is a bit large. That's a bit bad. Also, some message formats are sort of mixed. That's pretty bad. So here's what I've been through so far. First, I thought, well, this ain't so bad. I'll just make a Regex for every type of message there is, get the parameters from named groups in the match, and be done with it. It was all good until I got to about 5 of those and realized I wasn't nearly half way through the message types yet, and the function that picked the regex and figured out which matched was getting quite long. So then, I decided, ok, we'll generalize this a wee bit. So I made a class which takes in regex-delegate pairs, and then automatically goes through all the expressions it knows about, and whichever matches, it automatically calls it's correespondent delegate. This seemed like a very nice solution until I ran into these mixed format messages. Basically, we can have a message like: Application loaded module A Application couldn't load module B Or we can have messages like: Application finished successfully Application finished with error #blah Or we can have mixed messages like: Application finished with error #blah, because it couldn't load module B So at first, I was like, whatever, I'll just try to cover every possible case, how hard could it be? Well, it might not be too hard, but it sure as hell is tedious, and I'm afraid to even think what happens when the aforementioned third party decides to change their application, and changes the log file format in the process. It just seems like a bad thing to do in general. So then my thought was to use some sort of scanner and parser generator. I got myself ANTLR, and played around with that. However, it almost seems to be overkill to use it to parse the log one line at a time, and the code it generates is a wee bit slow for my needs (not to mention, it kinda sucks to use a java-based application to generate my .NET code). So... I was wondering if someone knows of some lightweight framework for simple parsing. I would appreciate any suggestions here. :)
  4. Most ridiculous line of code you have seen?

    Ugliest line of C# I've ever seen: string[] parts = someString.Split(new String(@"\")[0]); Most evil line of C I've ever seen (this was a prank played on a friend): fclose(stdout); Most evil line of C code I want to see (as a future prank played on a friend): #define sizeof(x) rand() ;) Vovan
  5. Quote:Original post by iMalc Quote:Original post by UnshavenBastard Maybe I should start a petition, collecting signatures, to Anders Hejlsberg that he makes -= and += etc overloadable in the next version? ;-)I'm curious; What would be your reasoning? I believe his reasoning is simple: if we overload operator-, it needs to return a new instance of vector. However, with the operator-=, you operate on the object to the left in place, hence saving a memory alloc and making code a tiny bit more efficient. I would really like to see how much of a difference this actually makes, but that'd be my thinking on this one. Vovan
  6. C# Flashing Problem

    Well, debugging it with a break-point is kind of hard, because it will fire at the slightest mouse move, and this shaking behavior manifests itself best with large moves. (Incidentally, conditional breakpoints would actually work nicely here. Stick one in there with the condition (dx < -100 || dx > 100).) yadango, if you put a Console.WriteLine("{0},{1}", dx, dy); after you get your deltas, it's quite illuminating. The mouse motion event fires twice, with opposite deltas. What I suspect happens is that when you move the control, the new mouse position over it registers, and hence, the new mouse move event is fired, this putting the control back where it was, which causes a new mouse event to fire, etc ad infinitum, until you let go of the button. The quick and dirty solution is to unregister the OnMouseMove event handler before this.SuspendLayout(), and reregister it after this.ResumeLayout(). A better solution would be to register to listen for the Move event as well, and handle the this.xPos, and this.yPos for the mouse there, so that when the new mouse move event fires, it doesn't send the control flying back to where it was before. Vovan
  7. Well, the thing about DirectInput is, it doesn't know or care where the mouse is. :) This is fine for games where you use the mouse without a cursor (ie aiming in FPS). This is not fine for places where you need a cursor (ie main menu GUI). So, if you do care about where the mouse is, you have to keep track of it yourself. :) See these resources for some help on how to accomplish that: Developing a GUI Using C++ and DirectX Moving Your Game to Windows, Part II: Mouse and Joystick Input <-- Really old article, so code is pretty useless, but it goes over the concepts. Hope that helps, Vovan
  8. Furious, To make the long story short, Delete is an instance method, which means you need to get your hands on the ManagementObject representing the share, and then invoke the delete method on that. Then the share that the management object represents will be killed. I threw together a quick (incomplete and inefficient) wrapper class for Win32_Share, which you may find below, along with a piece of testing code, which seems to work fine. using System; using System.Collections.Generic; using System.Text; using System.Management; namespace SharingTest { class Win32Share { public enum MethodStatus: uint { Success = 0, //Success AccessDenied = 2, //Access denied UnknownFailure = 8, //Unknown failure InvalidName = 9, //Invalid name InvalidLevel = 10, //Invalid level InvalidParameter = 21, //Invalid parameter DuplicateShare = 22, //Duplicate share RedirectedPath = 23, //Redirected path UnknownDevice = 24, //Unknown device or directory NetNameNotFound = 25 //Net name not found } public enum ShareType: uint { DiskDrive = 0x0, //Disk Drive PrintQueue = 0x1, //Print Queue Device = 0x2, //Device IPC = 0x3, //IPC DiskDriveAdmin = 0x80000000, //Disk Drive Admin PrintQueueAdmin = 0x80000001, //Print Queue Admin DeviceAdmin = 0x80000002, //Device Admin IpcAdmin = 0x80000003 //IPC Admin } private ManagementObject mWinShareObject; private Win32Share(ManagementObject obj) { mWinShareObject = obj; } #region Wrap Win32_Share properties public uint AccessMask { get { return Convert.ToUInt32(mWinShareObject["AccessMask"]); } } public bool AllowMaximum { get { return Convert.ToBoolean(mWinShareObject["AllowMaximum"]); } } public string Caption { get { return Convert.ToString(mWinShareObject["Caption"]); } } public string Description { get { return Convert.ToString(mWinShareObject["Description"]); } } public DateTime InstallDate { get { return Convert.ToDateTime(mWinShareObject["InstallDate"]); } } public uint MaximumAllowed { get { return Convert.ToUInt32(mWinShareObject["MaximumAllowed"]); } } public string Name { get { return Convert.ToString(mWinShareObject["Name"]); } } public string Path { get { return Convert.ToString(mWinShareObject["Path"]); } } public string Status { get { return Convert.ToString(mWinShareObject["Status"]); } } public ShareType Type { get { return (ShareType)Convert.ToUInt32(mWinShareObject["Type"]); } } #endregion #region Wrap Methods public MethodStatus Delete() { object result = mWinShareObject.InvokeMethod("Delete", new object[] { }); uint r = Convert.ToUInt32(result); return (MethodStatus)r; } public static MethodStatus Create(string path, string name, ShareType type, uint maximumAllowed, string description, string password) { ManagementClass mc = new ManagementClass("Win32_Share"); object[] parameters = new object[] { path, name, (uint)type, maximumAllowed, description, password, null }; object result = mc.InvokeMethod("Create", parameters); uint r = Convert.ToUInt32(result); return (MethodStatus)r; } // TODO: Implement here GetAccessMask and SetShareInfo similarly to the above #endregion public static IList<Win32Share> GetAllShares() { IList<Win32Share> result = new List<Win32Share>(); ManagementClass mc = new ManagementClass("Win32_Share"); ManagementObjectCollection moc = mc.GetInstances(); foreach (ManagementObject mo in moc) { Win32Share share = new Win32Share(mo); result.Add(share); } return result; } public static Win32Share GetNamedShare(string name) { // Not a very efficient implementation obviously, but heck... This is sample code. ;) IList<Win32Share> shares = GetAllShares(); foreach (Win32Share s in shares) if (s.Name == name) return s; return null; } } class Program { static void Main(string[] args) { // Create a share first: Win32Share.MethodStatus result = Win32Share.Create("C:\\temp", "Temp", Win32Share.ShareType.DiskDrive, 10, "My Temp Folder", null); if (result == Win32Share.MethodStatus.Success) { Console.WriteLine("Yay, we created a temp share!"); Win32Share tempShare = Win32Share.GetNamedShare("Temp"); Win32Share.MethodStatus deleteResult = tempShare.Delete(); if (deleteResult == Win32Share.MethodStatus.Success) { Console.WriteLine("Yay, we deleted temp share!"); } } } } }
  9. Well, I guess the first question to ask yourself when writing anykind of document like that (and an answer to which will help us help you [smile]) is "Who is the intended audience?" I know this can be kinda vague and everybody says it, so it loses its impact a bit, but yeah, it's important. So the first thing we want to figure out is this: is this document intended for internal or external consumption? Is the build tool going to be distributed to someone outside the company along with the tool itself? And if so, is it going to be distributed as a standalone tool, or just a thing to help them build the main piece of software that your company sells? Either way, with anything that's going to be used outside the company, you want to put as many details about the operation of the tool as possible, including caveats and anything extraordinary one needs to make it work. I suspect, however, this tool if for internal use only. In this case, you still need to consider: is this document for developers that are only going to use it? Or maybe at some point they might want to look at and modify the code of the tool itself for some reason? In the latter case, you might want to not only document the way the tool woks, but also talk about how it is implemented. In general, when I write a document like that, I put first a little overview section which lists what the tool does and a little about how it does it, and then one section for every major bit of fucntionality, including a detailed description as to what's going on, and any gotchas the user may encounter, and then maybe a separate section for caveats that didn't fit anywhere in particular. So, for example, if I were writing a document for an imaginary tool, I would first put a section of overview. In there I would say something like "The such-and-such tool is used to build software and package it for distribution to customers. It takes in a directory that is the root of where the project to be built lives and attempts to compile all the source files it recursively finds. Once the compilation succeeds, the tool will collect all the project's resource files and package them into a distributable archive. Once all the resources are collected, the tool generates an MSI installer ready to be dsitributed to the customers, which contains all the necessary executables, resources, and configuration." Ya know. Something like that. Adapt to your needs, and expand a bit, like what the heck is an installer. ;) Now, you got yourself an overview like that. Read over it and figure out what are the major steps. If you read my fictitious overview, you will notice there are four major bits of functionality in the tool: analyzing the directory structure to identify source files and resources, compiling sources, packaging resources, and generating an installer. So I would put a separate section in the document for each of those. The analyzing directory structure bit could like something like this: "The tool expects a directory command-line parameter at startup. This parameter will be used to locate the project to be distributed. If the directory pointed to by this path does not exist, the tool will quit with an error (error description goes here). Once the directory is located, the tool will recursively go through each file in this directory and its child directories. It will consider all .java, .c, .h, .cpp, and .hpp files to be source files, and they will be included in the compilation process. It will consider all .txt, .gif, and .help files resources, which will be packaged for release with the executable. Files with other extensions will be ignored." Notice here I would list any error that can be encountered during this stage of the execution of the tool, and if it's not obvious, explicitly say what may be a possible solution. Like, as above, if the directory doesn't exist, it's kind of obvious that you have to... you know... provide a valid directory. ;) However, in some tools I've seen, they might rely on some sort of environment variable. So, say our imaginary tool expected an environment variable telling it which version of the java compiler to use. Then definitely stick that into the section on the compilation process, and tell the user what the error might be if the environment variable is missing, how to fix this, and what to do if they can't set environment variables (contact sys admin, blah blah blah). Also, this reminded me, if the tool requires special start-up procedures, like it requires (or even supports) a bunch of startup command-line parameters, it would probably be a good idea to dedicate a separate section to enumerating the possible parameters, what kind of values they need, what happens if they are not provided, and such. Hmmm... What else... Right, so if there is anything at all quirky about the tool, make sure to mention it. Like did you just get it and it magically worked on your computer? I bet you had to do something to make it work. ;) List it. And in general, if you are in doubt whether something is obvious enough to be ignored in the document... It isn't. ;) First of all, remember there are people out there who aren't as smart as you, so if something is obvious to you, it may not be to them. Secondly, and even more importantly, recognize that often times things only seem obvious to you because you've looked at them for a long time. Someone who hasn't seen the tool before will be easily confused. Finally, if there is any kind of development involving this tool envisioned for the future, like some sort of plug-in system to support other compilers, make sure to write about how one might go about developing something like that. Wow... I've just written a document about writing documents. :) Let me tell you: once you've written a few documents thinking just about how to make 'em long enough to satisfy the superior, once you have that experience... You'll be praying for the ability to write concisely, instead of producing long-wided discussions that are too huge for anyone to read without going insane. ;) ... Hope that helps. :D -- Vovan
  10. Simon, Generally, these kinds of posts go into the Your Announcements forum, and cross-posting is not encouraged. Regarding the engine itself, first of all, good job getting it done. ;) I'll definitely check it out. -- Vovan
  11. Quote:Original post by medevilenemy that isn't really true. Each 'tile' could represent an object, modeled by a set of relevant sprites. There could simply be a destruction sprite animation. Which is why I said inconvenient, not impossible. :) I still believe that for instance for Scorched Earth it would be very inconvenient to do this. Recall all the weapons it has. There are weapons that blast the soil away, burn it off, and of course, create more soil. Recall also that things like moles (IIRC that's what they were called) would dig into the soil and explode underground - then the terrain above would fall down to fill the gap. If this was done with tiles bigger than one pixel in size, it would be a major pain in the ass, as for every weapon you create, you would have to handle a bundle of special cases with the terrain. And if, OTOH, every tile you have is one pixel in size, well... To me then they aren't really tiles any more. ;) -- Vovan
  12. [web] Review My Site!

    Gin, It looks good, except for a couple things: 1. Like someone said, what is up with the radio button on the front page? It bothers me when I see a form control and I don't know what it does. :) 2. More seriously, in your image submit form is a hidden input called "MAX_FILE_SIZE". Now, I haven't checked this, but I am guessing you use this to check against the upload size and disallow files too big. I want to point out that I could write my own form, set MAX_FILE_SIZE to a huge number, and submit that to your script to work around this "restriction". Now, you may have addressed this somehow, in which case that's ok, but in general it is not safe to get data that affects the stability of your server from a request provided by the user. Vovan
  13. Quote:Original post by Ey-Lord Can you think of games 2D that cannot be made under some kind of tile system ? Consider a game like Scorched Earth, or the original Worms, or Lemmings, or Soldat. Since the terrain is destructible, it might be sort of unnatrual and a bit inconvenient to use standard tiles, IMO. -- Vovan
  14. Quote:Original post by BradSnobar That's likely a first chance exception. Good luck trying to figure out what is causing it though. Actually it's not that hard. Firstly, you can still run Release-mode compiled apps in the debugger. Secondly, you can tell the debugger to break on an exception throw even if it is caught somewhere (in other words, it will break on first-chance exceptions). See here for how to do that in VS2k3, and the same thing works in 2k5 too: How to Stop on First Chance Exceptions - Visual Studio .NET 2003 -- Vovan
  15. Worst interview

    Quote:Original post by leiavoia That's only good if you WANT to work 50-60 hours a week. Me personally, i have too many other spare-time things i want/need to do. Getting rich is not my goal in life. As long as i can make enough money to live on and have a little bit left over, that's enough. If i could work just 10 hours a week and make $100 an hour, i'd do it! Oh, I definitely don't disagree. The reason I was giving this example was to just underscore JohnBolton's point: he said no to overtime and didn't make it in, whereas a friend of mine said yes, and did. I guess that's not too much of a surprise with this company, however.