Jump to content

  • Log In with Google      Sign In   
  • Create Account


Phil123

Member Since 08 Jul 2012
Offline Last Active Yesterday, 07:43 AM
-----

Topics I've Started

Industrial Strength Hash Table

12 March 2014 - 12:26 PM

I've been enjoying the coding horrors forum for a while, so I decided to post a snippet of code that I found in a large c++ project that I'm (unfortunately) a part of.  Normally I wouldn't poke fun at code like this, but I couldn't resist this one.

 

Enjoy.

#pragma once

#include "Includes.h"



template<class T>

class Dictionary

{

private:

    std::vector<std::string> keys;

    std::vector<T> values;

public:

    Dictionary()

    {

        keys = new std::vector<std::string>{};

        values = new std::vector<T>{};

    }



    ~Dictionary()

    {

        delete[] keys;

        delete[] values;

    };



    std::vector* Values() { return &values; };

    std::vector* Keys() { return &keys; };



    size_t size() { return keys.size(); }



    void Add(std::string _key, T value)

    {

        keys.push_back(_key);

        values.push_back(value);

    };

    void Remove(std::string _key)

    {

        for (size_t i = 0; i < keys.size(); i++)

        {

            if (keys.at(i) == _key)

            {

                keys.erase(keys.begin() + i);

                values.erase(values.begin() + i);

                break;

            }

        }

    };

    T Get(std::string _key)

    {

        for (size_t i = 0; i < keys.size(); i++)

        {

            if (keys.at(i) == _key)

            {

                return values.at(i);

            }

        }

        return nullptr;

    };

};


XNA Access Violation Exception

30 April 2013 - 09:38 PM

System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=Microsoft.Xna.Framework
  StackTrace:
       at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.IsEventRegistered(EventType type)
       at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.UnregisterEvent(EventType type)
       at Microsoft.Xna.Framework.Audio.KernelMicrophone.ShutdownCaptureEngine()
       at Microsoft.Xna.Framework.Audio.MicrophoneUnsafeNativeMethods.ShutdownCaptureEngine()
       at Microsoft.Xna.Framework.Audio.AudioRendererShutdownHandler.AppExitingEventHandler(Object sender, EventArgs args)
  InnerException:
 

Every now and then, I get a System.AccessViolationException when closing the program and all the information I'm given is above.  I suppose it isn't really an issue as if the program crashes when I'm closing it, so it probably isn't the absolute end of the world (compared to it crashing during run time).  But I still would prefer for this to not happen.  Unfortunately, I don't know what's directly causing it, and I'm not sure it'd be helpful to post my audio manager classes either since the problem seems to be within the framework itself.

 

Any ideas?


Getting Started with OpenGL

15 April 2013 - 09:42 PM

I'm looking to purchase a book that will help me learn OpenGL (with C++).  I've looked into a few but there seem to be some mixed opinions about said books, so here I am - asking for advice.

 

This book shouldn't assume I know everything there is to know about 3D math, and should be a "learning book" instead of a "reference book."  And before someone suggests a website (which is fine if it's a great resource), the reason I'm looking for a book is simply a learning preference.

 

If this is the entirely wrong approach, then feel free to steer me in the right direction.


Legal Questions

03 February 2013 - 11:26 PM

I develop my own games for the purpose of building up a portfolio that will end up getting me a job after college.  Now, my problem is that I don't do my own art/music/sound, so I rely on open source stuff generally.  More specifically, I get art/music/sound from many, many different sources and I'm not always sure if it's considered open source or not.  SO:

 

For a non-profit strictly-portfolio game where I will provide the source code upon request, is it legal to use open source images/sound/music (without giving credit - I don't want to get slammed for missing someone in the credits).

 

Also, if you modify an existing image, sound or music file, is it now your work?  Their work?  Partly both?  How does that work?  What if you completely replicate it from scratch?  Is it still considered their work?


Lack of Image/Music Files

21 January 2013 - 10:50 PM

Lately, I've been cloning games in C# with XNA (ex: tetris, bejeweled, and a few others) for the purposes of learning.  (Note that there isn't an extreme amount of polish as I'm doing this simply as an exercise).  Now that I have a basic understanding of how this stuff works I'd like to work on more advanced projects.  One that comes to mind (but may be slightly overboard for my current programming ability) is Final Fantasy Tactics.  The problem with this is I have absolutely no idea how I would ever get textures (or heck, music or sound) for more advanced projects like these (which is the only thing currently stopping me).

 

Before you say - "oh, just go to X website and download 7 images from there, and go to Y website and get 4 images from there" - I want to mention that these will not be polished products.  This is an exercise so if I have to hunt down images and whatnot then it simply ruins the entire point.

 

Any ideas?

 

(Note: I'm comfortable with C++, C# and XNA stuff, currently learning AS3 and Java in school, so if I should devote my time toward something else as a game programmer, I'm open to those suggestions as well).


PARTNERS