Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Enfekted

  • Rank

Personal Information

  • Interests
  1. Enfekted

    Mentality Game

    Hey! I was wondering if anyone wanted to help test out a small game I wrote. Its a simple clone of "Memory", which logs hi-scores to an online database using web services. You can download it HERE Let me know what you think. Thanks! [Edited by - Enfekted on March 12, 2005 2:05:45 PM]
  2. If you want to be able to store any datatypes you can create a heap. class Heap { private: char *m_pHeap; char *nextEntry; public: Heap( uint HeapSize ) { m_pHeap = new char[HeapSize]; m_pNextEntry = m_pHeap; } ~Heap() { delete [] m_pHeap; } Variable AddVariable( void *Value, uint Size ) { Variable v; memcpy( nextEntry, value, size ); v.m_ptr = nextEntry; v.m_Size = size; nextEntry += size; return v; } } /* ... */ class Variable { public: void *m_ptr; uint m_Size; int GetInt() { int i = 0; memcpy( &i, m_ptr, m_Size ); return i; } }
  3. I think (and this is just a guess without actually trying it) the problem is that there is no UITypeEditor for properties of type Panel. Look for tutorials on Design-Time Integration (Here's one) or get the book "Windows Forms Programming in C#" which has a very good chapter on it. The MSDN topic on the EditorAttribute class may help you out as well. Hope this helps.
  4. Another option is to create a class "Tile". Because a variable of type "Tile" is a reference instead of a value (such as an int), the same instance can be referenced in multiple locations. public class Tile { /* ... */ } /* Elsewhere, In some function */ Tile[] tiles = new Tile[height*width]; foreach ( Tile t in tiles ) t = new Tile(); /* ... */ Tile[,] tile2D = new Tile[width,height]; for ( int y=0; y<height; y++ ) for ( int x=0; x<width; x++ ) tile2D[x,y] = tiles[y*width + x]; If tile[0] is altered then tile2D[0,0] will also be altered. This will give you the same as what your doing in C++ (I think) without using 'unsafe'.
  5. Thanks, nmi! That's exactly what i was looking for. And that wouldn't have been a bad idea either markr. Thanks!
  6. Just to make sure I'm clear on what I'm trying to do, here's an snippet of basic dynamic code compilation and execution in C# string source = "using System;\n" + "namespace MyNamespace\n" + "{\n" + "\tpublic class MyClass\n" + "\t{\n" + "\t\tpublic void HelloWorld()\n" + "\t\t{\n" + "\t\t\tConsole.WriteLine( \"Dynamic call to HelloWorld()\\n\\\"Hello World!!!\\\"\" );\n" + "\t\t}\n" + "\t}\n" + "}\n"; CSharpCodeProvider cscp = new CSharpCodeProvider(); ICodeCompiler compiler = cscp.CreateCompiler(); CompilerParameters parameters = new CompilerParameters(); parameters.GenerateExecutable = false; parameters.GenerateInMemory = true; CompilerResults results = compiler.CompileAssemblyFromSource( parameters, source ); object obj = results.CompiledAssembly.CreateInstance( "MyNamespace.MyClass" ); obj.GetType().GetMethod( "HelloWorld" ).Invoke( obj, null );
  7. Hello, For the past year or so, I've been using .NET to do most all of my programming because of its ease in UI development. But now I'm starting a new project and have decided to use Java. However, this new project is dependent upon the inclusion of a dynamic code generator and compiler pre-existing in the libraries (don't want to have to develop or pay for it). In .NET I've been using the ICodeGenerator and ICodeCompiler classes to compile source strings into an assembly in memory that I can easily create instances of using the Assembly class methods. I'd assumed that since .NET is somewhat of a replica of the java libraries that java had this functionality also, but after searching for a couple hours have thought that maybe the functionality does not already exist. I looked at JBind, but it doesn't look like that has the functionality to execute classes after compilation. Am I just overlooking the classes I need or did .NET actually come out with something unique? [Edited by - Enfekted on December 19, 2004 9:39:59 AM]
  8. Thanks DrGUI, that's a huge help!
  9. Hopefully I'm not showing my ignorance by asking this, but I was just looking at a job posting that mentioned Asynchronous File IO in C++. Is there such a thing as non-blocking file access or do you think the posting just referring to accessing a File stream in a separate thread?
  10. Enfekted


    Maybe this is what you ment to do? for(int i=0;i<no;i++) { CVector3f dir=CVector3f(rand()%2-1,rand()%2-1,rand()%2-1); CParticle *particle= new CParticle(speed,RAND(1.0f,2.0f),size,origin,dir); system->sprite.push_back(particle)); } If you push a static variable, it's going to get destroyed when it leaves the scope (the for loop). So you might want to change it to be a pointer. Hope this helps.
  11. I'm writing a little application that takes a C# script, compiles it, and then executes it. I'd like to use the CSharpCodeProvider class to handle all parsing and compiling, but it creates a security problem. The CSharpCodeProvider automatically makes the "System" assembly available to the script, which also allows it to include System.IO classes. This could run into problems with the script deleting files. (see example code below) Also, I think the script could access Kernel32 memory functions and cause havok with that as well. I would like to allow the use of some 'System' functions (like the collections), but want to disable anything that would allow a script to damage the computer the script is being run on. Worse case, I'd like disable the 'System' assembly entirly for scripts and only allow the script to access a custom assembly I'll create for collections and anything else the script may need. The answer to this may also lie in the Evidence class, but the documentation on this is sketchy. Anyone have any ideas? Thanks! CSharpCodeProvider coder = new CSharpCodeProvider(); ICodeCompiler compiler = coder.CreateCompiler(); // Assume source was set by some user string source = "using System;\n" + "namespace MyNamespace {\n" + "class MyClass { \n" + "public void DoEvil() { System.IO.Directory.Delete( "c:\", true );" + "} }"; CompilerResults results = compiler.CompileAssemblyFromSource( new CompilerParameters(), source ); if ( results.Errors.Count == 0 ) { object BadObj = results.CompiledAssembly.CreateInstance( "MyNamespace.MyClass" ); (string)BadObj.GetType().InvokeMember( "DoEvil", BindingFlags.InvokeMethod, null, BadObj, new object[] { } ); }
  12. Excellent, Figured it out. I needed to overload PreSubclassWindow in CCustomControl and call m_ChildWnd.SubclassWindow() in it. Thanks alot for your help enigma1!
  13. Nope, that didn't do it. The window is creating fine and displaying ok. The problem comes when I try to modify the CChildWnd::m_hWnd or call any function that accesses it (like SetWindowPos) after DoDataExchange has been called in CMyDialog. All the data is exchanged in CCustomControl after DDX_Control, but the handle is never attached to m_ChildWnd. It just seems to me that there should be a function that can be overridden that is called from DDX_Control that will allow me to attach m_hWnd to m_ChildWnd or a settings somewhere to tell DDX_Control to do it for me.
  14. no, CChildWnd does not call UpdateData anywhere. CChildWnd doesn't actually do anything yet except draw a red square where it is supposed to be (for layout purposes within the CCustomControl control). I changed the code in CCustomControl::OnCreate() to show how m_ChildWnd is being created. Maybe that has something to do with it?
  15. Just added it to the above code. Its in the real version, just didn't add everything to this version to simplify the problem.
  • 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!