Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AdventWolf

Pages: 1 [2] 3 4
16
General / (Solved) Need help with errors after updating SFML
« on: May 27, 2011, 04:34:33 am »
Sure, here it is.
http://www.sendspace.com/file/9ah5nh
Thanks for the help.

17
General / (Solved) Need help with errors after updating SFML
« on: May 26, 2011, 08:03:35 pm »
I deleted all of the SFML files and redownloaded them. I rebuilt SFML and linked directly to a folder that has the libs in it on the compiler tools. I'm getting the same error. Should I reinstall Visual Studio?

18
General / (Solved) Need help with errors after updating SFML
« on: May 26, 2011, 05:11:39 pm »
Did the update make it so they have to be in a certain order now?

I tried different orders but it didn't make a difference. I might have to reinstall sfml.

19
General / (Solved) Need help with errors after updating SFML
« on: May 26, 2011, 01:23:15 am »
Would anymore mind uploading a working project file using the most recent version of SFML2 that works with just a couple of lines of code?

I have no idea what is wrong with mine =/.

20
General / (Solved) Need help with errors after updating SFML
« on: May 25, 2011, 10:10:44 pm »
I updated to SFML 2 in January. I hadn't updated SFML again until today.
When I try to code anything with SFML I get errors.

I've tried compiling in debug/release with static and non-static libs and using SFML_STATIC in the preprocessor commands.

I'm currently trying to compile in Debug with non-static libs.
I'm linking to sfml-main, system, graphics, and window.

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow WINDOW(sf::VideoMode(400,400),"Title");
return 0;
}


Code: [Select]
1>example.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUContextSettings@1@@Z) referenced in function _main
1>C:\User\Documents\Visual Studio 2008\Projects\example\Debug\example.exe : fatal error LNK1120: 1 unresolved externals

21
Network / need help with an error message
« on: May 25, 2011, 09:43:57 pm »
Can you post a code sample?

22
Graphics / Need clarification...
« on: May 25, 2011, 08:32:12 pm »
There is an example in the wiki that I used called "Frame, Anim, Animated."
Basically you have a image file that has multiple character movement actions and based on which buttons your are pressing, your character will display that movement. It should help you out.

23
Graphics / Health bar?
« on: May 25, 2011, 08:17:58 pm »
I have used
Code: [Select]

HealthBar.SetSubRect(sf::IntRect(0,0,int(currentHP/maxHP*229),14));


229 being the width, and 14 is the height of your sprite.

24
Network / need help with an error message
« on: May 25, 2011, 07:59:28 pm »
When you want to use a dll, you need to link the .lib file.

There should be sfml-network.dll and sfml-network.lib.
Link to sfml-network.lib.

25
General / Inventory system for text based rpg/mud
« on: May 25, 2011, 07:56:19 pm »
Instead of making a class for a specific item, you should make a broad "Item" class that you can create your items under.

I think the problem you might have is that you are trying to create a string by the name of your class in the private declaration. Also do you have your class functions coded?

Code: [Select]

class Item
{
public:
   Item();
   Item(string Name, string ItemDesc, int DatabaseID, int ItemType, int Attack, int Defense, int GoldValue, int Stack, int MaxStack, bool Stackable);
   string GetItem() {return Name;}
   string GetItemDesc() {return ItemDesc;}
   int GetDatabaseID() {return DatabaseID;}
   int GetItemType() {return ItemType;}
   int GetAttack() {return Attack;}
   int GetDefense() {return Defense;}
   int GetGoldVale() {return GoldValue;}
   int GetStack() {return Stack;}
   int GetMaxStack() {return MaxStack;}
   bool GetStackable() {return Stackable;}
private:  
   string Name;
   string ItemDesc;
   int DatabaseID;
   int ItemType;
   int Attack;
   int Defense;
   int GoldValue;
   int Stack;
   int MaxStack;
   bool Stackable;
};


Then you could implement it by:

Code: [Select]
Item CopperSword("Copper Sword","Desc",1,1,1,1,1,1,1,false);

26
General / Program crashes when getting buffer for audio file
« on: January 15, 2011, 12:16:58 am »
I finally got it, thank God for pointers.

27
General / Program crashes when getting buffer for audio file
« on: January 14, 2011, 10:08:00 pm »
I deleted all of the files and removed the evidence of the dat files and re-made the files. So far the Image one works perfectly and I am trying to manage the audio version.

The name of the audio file is MenuSong.ogg.

I've got this error:
Code: [Select]
SoundManager::LoadSound(sf::Music * temp=0x00000000, std::basic_string<char,std::char_traits<char>,std::allocator<char> > sound_id="Data/Audio/MenuSong.ogg")  Line 46 C++


Code: [Select]
//sf::Music* MenuSong
SOUND.LoadSound(MenuSong,"Data/Audio/MenuSong.ogg");


Code: [Select]
void SoundManager::LoadSound(sf::Music* temp, std::string sound_id)
{
temp_data = data.GetSound(sound_id); //char* temp_data
temp_size = data.GetSoundSize(sound_id); //char* temp_size
if(temp_data == NULL)
{
std::cout << "Error Loading... " << sound_id << std::endl;
}
else
{
temp->OpenFromMemory(temp_data, temp_size);
}
}


These are the data functions:

Code: [Select]
char* SoundDAT::GetSound (std::string file_id)
{
    //The input file stream from which we want information
    std::ifstream datfile;
 
    //Cleaning properly an ancient file loaded
    if (m_buffer != NULL)
    {
        delete (m_buffer);
        m_buffer = NULL;
    }
 
    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++)
    {
std::cout << "ID: " << file_id << std::endl;
std::cout << "i: " << m_entries[i].name << std::endl;
        //If we found it
if (m_entries[i].name == file_id)
        {
            //We are allocating memory to the buffer
            m_buffer = new char[(m_entries[i].size)];
            //Simple error catch
            if (m_buffer==NULL)
                return (NULL);
            //Opening the DAT file ot read the file datas needed
            datfile.open (m_datfile.c_str(), std::ifstream::in | std::ifstream::binary);
            if (datfile.is_open())
            {
                //Going to the right position
                datfile.seekg (m_entries[i].offset, std::ios::beg);
                //Reading
                datfile.read (m_buffer, m_entries[i].size);
                //We can close the DAT file
                datfile.close();
                //Returning the buffer
std::cout << "RETURNING BUFFER" << std::endl;
std::cout << "BUFFER: " << m_buffer << std::endl;
                return (m_buffer);
            }
        }
    }
    //Finally, there is no such file in our DAT file
std::cout << "RETURN NULL" << std::endl;
    return (NULL);
}

long int SoundDAT::GetSoundSize (std::string file_id)
{
    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++)
    {
        //If we found it
        if (m_entries[i].name == file_id)
        {
            //Returning the size of the file found
            return (m_entries[i].size);
        }
    }
    return (0);
}


The program crashes at the end of the LoadSound function.
Though if I don't use pointers and I just put this:
Code: [Select]
sf::Music temp1;
temp1.OpenFromMemory(temp_data,temp_size);

Then it doesn't crash. However if I switch out the sf::Music* temp with sf::Music temp inside the function definitions, then I get the noncopyable error when trying to compile:
Code: [Select]
error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'

28
General / Program crashes when getting buffer for audio file
« on: January 14, 2011, 05:32:40 pm »
Yeah, data is the same for both of the classes. data is just the DAT class that holds creates the DAT file. AUDIO and IMAGES are the managers of the data. But going through the debugger some more I see it crashes inside the vector:

Code: [Select]
//line726
                        size_type size() const
{ // return length of sequence
return (_Mylast - _Myfirst); //crashes here
}


Code: [Select]
#if _HAS_ITERATOR_DEBUGGING
if (size() <= _Pos) //crashes here
{
_DEBUG_ERROR("vector subscript out of range");
_SCL_SECURE_OUT_OF_RANGE;
}
 #endif /* _HAS_ITERATOR_DEBUGGING */


It looks like it crashes because of the size of the vector, but it is definitely not the problem.
It just seems as if the variables go out of scope inside the "GetImage" function.

I got this error when trying to run the program:
Code: [Select]
_block_type_is_valid phead- nblockuse
I read up on it and it seems like it happens when a program is trying to access a pointer to char that has been deleted, but the setup of the class is exactly the same as the other class so I don't know why the other hasn't given me any problems.

EDIT: I deleted the class, and now the other working DAT class is giving me the error.

29
General / Program crashes when getting buffer for audio file
« on: January 13, 2011, 11:22:03 pm »
It is crazy, I have had a working dat file for the images i my program so I just copied all of the code and made a new class and just renamed it and switched "Image" to "Audio". It is the same exact code but when I I try to execute this:

Code: [Select]
char* buffer0 = IMAGES.data.GetImage("Data/Images/test.png");
char* buffer  = AUDIO.data.GetImage("Data/Images/test.png");


No matter how I switch the code around, it only crashes on the Audio Version. I'm not even loading audio, I'm just trying to load the same image. The code is exactly the same! I just don't understand what the problem is.

EDIT: For some reason in this function
Code: [Select]
char* AudioDAT::GetImage (std::string filename)
{
    //The input file stream from which we want information
    std::ifstream datfile;
    //Cleaning properly an ancient file loaded
    //if (m_buffer != NULL)
    //{
    //    delete (m_buffer);
    //    m_buffer = NULL;
    //}
std::cout << m_entries[1].name << std::endl;
    //First, we have to find the file needed
    /*for (unsigned int i=0; i<m_header.nb_files;i++)
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //We are allocating memory to the buffer
            m_buffer = new char[(m_entries[i].size)];
            //Simple error catch
            if (m_buffer==NULL)
                return (NULL);
            //Opening the DAT file ot read the file datas needed
            datfile.open (m_datfile.c_str(), std::ifstream::in | std::ifstream::binary);
            if (datfile.is_open())
            {
                //Going to the right position
                datfile.seekg (m_entries[i].offset, std::ios::beg);
                //Reading
                datfile.read (m_buffer, m_entries[i].size);
                //We can close the DAT file
                datfile.close();
                //Returning the buffer
                return (m_buffer);
            }
        }
    }*/
std::cout << "END" << std::endl;
    //Finally, there is no such file in our DAT file
    return (NULL);
}
It won't recognize the variables of the class, if I try to use m_buffer it just crashes, if I try to use m_entries, it crashed, anything to do with the class just crashes. I can clearly see the variables are inside the class, plus it is the same code as the other class, except renamed. Why would it do that?

30
General / Program crashes when getting buffer for audio file
« on: January 11, 2011, 03:02:15 am »
I've been trying to work this out for a while but I keep getting errors or the program crashes. I have no idea why it is crashing, I'm using pretty much the same method as the sample from the tutorial here. http://sfml-dev.org/wiki/en/tutorials/formatdat

Code: [Select]
class AudioDAT
{
private :
    sAudioDATHeader m_header; /// file header
    std::vector<sAudioEntry> m_entries; /// vector of files entries
    char* m_buffer; /// Buffer pointing on a file in memory
public :
...
    long int GetAudioSize (std::string filename);
};


Code: [Select]
//In AudioDAT.cpp
char* AudioDAT::GetAudio (std::string filename)
{
    //The input file stream from which we want information
    std::ifstream datfile;
 
    //Cleaning properly an ancient file loaded
    if (m_buffer != NULL) //Program crashes here
    {
        delete (m_buffer);
        m_buffer = NULL;
    }

    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++)
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //We are allocating memory to the buffer
            m_buffer = new char[(m_entries[i].size)];
            //Simple error catch
            if (m_buffer==NULL)
                return (NULL);
            //Opening the DAT file ot read the file datas needed
            datfile.open (m_datfile.c_str(), std::ifstream::in | std::ifstream::binary);
            if (datfile.is_open())
            {
                //Going to the right position
                datfile.seekg (m_entries[i].offset, std::ios::beg);
                //Reading
                datfile.read (m_buffer, m_entries[i].size);
                //We can close the DAT file
                datfile.close();
                //Returning the buffer
                return (m_buffer);
            }
        }
    }
    //Finally, there is no such file in our DAT file
    return (NULL);
}
...
long int AudioDAT::GetAudioSize (std::string filename)
{
    //First, we have to find the file needed
    for (unsigned int i=0; i<m_header.nb_files;i++) //Also crashes here
    {
        //If we found it
        if (m_entries[i].name == filename)
        {
            //Returning the size of the file found
            return (m_entries[i].size);
        }
    }
    return (0);
}


Code: [Select]
class AudioManager
{
std::vector<std::string> audio_container;

public:
AudioManager();
        AudioDAT data;
char * GetBuffer(std::string name);
long int GetSize(std::string name);
}


Code: [Select]
//In AudioManager.cpp
char* AudioManager::GetBuffer(std::string name)
{
char* buffer = data.GetAudio(name); //Crashes here
if (buffer == NULL)
    {
        std::cout<<"Read error"<<std::endl;
    }
return buffer;
}

long AudioManager::GetSize(std::string name)
{
return data.GetAudioSize(name);
}


Code: [Select]
//In application of code
//AUDIO is AudioManager
char* buffer = AUDIO.GetBuffer("Data/Audio/x1.ogg");//crashes here
long int size = AUDIO.data.GetAudioSize("Data/Audio/x1.ogg");//crashes here
        MenuSong.OpenFromMemory(buffer,size);

Pages: 1 [2] 3 4