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 - Vita

Pages: [1]
1
Network / I have problem receiving Data from UDP Socket
« on: August 31, 2011, 04:45:39 pm »
Hi,

I've done something wrong I'm trying to Query a HLDS server.

More info about query:
http://developer.valvesoftware.com/wiki/Server_queries

Here is the code:
Code: [Select]

#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include <iostream>
#include <string>
#pragma comment(lib,"sfml-network-s-d.lib")
#pragma comment(lib,"sfml-system-s-d.lib")
using namespace std;
#define A2S_INFO "\xFF\xFF\xFF\xFF\x54Source Engine Query"
#define A2S_INFO_LENGTH 25
//int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpArguments, int NumParameters)
int main()
{
cout << "PROGRAM STARTING..." << endl;
sf::Packet rcvPaket;
sf::IPAddress rcvIP;
unsigned short rcvPort;
cout << A2S_INFO << endl;

cout << "CREATING SOCKET..." << endl;
sf::SocketUDP sckClient;
cout << "SOCKET CREATED!" << endl;

cout << "BINDING PORT 6586..." << endl;
if(!sckClient.Bind(6586))
{
cout << "BIND FAILED !" << endl;
system("pause");
return 0;
}
cout << "PORT 6586 BINDED..." << endl;

cout << "SENDING PACKET..." << endl;
if(sckClient.Send(A2S_INFO,A2S_INFO_LENGTH,"85.25.35.235",27015) != sf::Socket::Done)
{
cout << "PACKET SENDING ERROR !" << endl;
system("pause");
return 0;
}
cout << "PACKET SENT!" << endl;

//sf::Sleep(1000);

cout << "RECEIVING PACKET..." << endl;
unsigned int rcvLen;
char * data = NULL;

if(sckClient.Receive(data,1028,rcvLen,rcvIP,rcvPort) != sf::Socket::Done)
{
cout << "PACKET RECEIVE ERROR !" << endl;
system("pause");
return 0;
}
//cout << "Data Len: " << rcvLen << " Data: " << data << endl;
printf("Data len: %d Data: %s\n",rcvLen,data);
cout << "PACKET RECEIVED!" << endl;

cout << "CLOSING SOCKET..." << endl;
sckClient.Close();
cout << "SOCKET CLOSED!" << endl;
cout << "END OF PROGRAM!" << endl;

system("pause");
return 0;
}


And Here is the program result:
Code: [Select]

PROGRAM STARTING...
    TSource Engine Query
CREATING SOCKET...
SOCKET CREATED!
BINDING PORT 6586...
PORT 6586 BINDED...
SENDING PACKET...
PACKET SENT!
RECEIVING PACKET...
Cannot receive data from the network (invalid parameters) <-- PROBLEM?
PACKET RECEIVE ERROR !
Press any key to continue . . .


If someone knows what is the problem please tell me.

Thanks in advance!

2
General / Make Error Linux Debian
« on: May 30, 2011, 05:57:37 pm »
Hello,
I recently tried to compile app on linux, but I could not even make and install the SFML lib.
Here is the code:
Code: [Select]

root@bt:~/SFML-1.6# make install all
make[1]: Entering directory `/root/SFML-1.6/src/SFML'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/System'
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/System'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Window'
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Window'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Network'
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Network'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Graphics'
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Graphics'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Audio'
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Audio'
make[1]: Leaving directory `/root/SFML-1.6/src/SFML'
make[1]: Entering directory `/root/SFML-1.6/src/SFML'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/System'
g++ -shared -Wl,-soname,libsfml-system.so.1.6 -o ../../../lib/libsfml-system.so.1.6 Clock.o Lock.o Randomizer.o Sleep.o Unicode.o ./Unix/Initializer.o ./Unix/Mutex.o ./Unix/Platform.o ./Unix/Thread.o -lpthread
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/System'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Window'
g++ -shared -Wl,-soname,libsfml-window.so.1.6 -o ../../../lib/libsfml-window.so.1.6 Context.o Input.o VideoMode.o Window.o WindowImpl.o ./Linux/Joystick.o ./Linux/VideoModeSupport.o ./Linux/WindowImplX11.o  -lX11 -lXrandr -lGL
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Window'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Network'
g++ -shared -Wl,-soname,libsfml-network.so.1.6 -o ../../../lib/libsfml-network.so.1.6 Ftp.o Http.o IPAddress.o Packet.o SelectorBase.o SocketTCP.o SocketUDP.o ./Unix/SocketHelper.o
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Network'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Graphics'
g++ -shared -Wl,-soname,libsfml-graphics.so.1.6 -o ../../../lib/libsfml-graphics.so.1.6 Color.o Drawable.o Font.o FontLoader.o GraphicsContext.o Image.o ImageLoader.o Matrix3.o PostFX.o RenderTarget.o RenderWindow.o Shape.o Sprite.o String.o View.o ./GLEW/glew.o ./libjpeg/jcapimin.o ./libjpeg/jcapistd.o ./libjpeg/jccoefct.o ./libjpeg/jccolor.o ./libjpeg/jcdctmgr.o ./libjpeg/jchuff.o ./libjpeg/jcinit.o ./libjpeg/jcmainct.o ./libjpeg/jcmarker.o ./libjpeg/jcmaster.o ./libjpeg/jcomapi.o ./libjpeg/jcparam.o ./libjpeg/jcphuff.o ./libjpeg/jcprepct.o ./libjpeg/jcsample.o ./libjpeg/jctrans.o ./libjpeg/jdapimin.o ./libjpeg/jdapistd.o ./libjpeg/jdatadst.o ./libjpeg/jdatasrc.o ./libjpeg/jdcoefct.o ./libjpeg/jdcolor.o ./libjpeg/jddctmgr.o ./libjpeg/jdhuff.o ./libjpeg/jdinput.o ./libjpeg/jdmainct.o ./libjpeg/jdmarker.o ./libjpeg/jdmaster.o ./libjpeg/jdmerge.o ./libjpeg/jdphuff.o ./libjpeg/jdpostct.o ./libjpeg/jdsample.o ./libjpeg/jdtrans.o ./libjpeg/jerror.o ./libjpeg/jfdctflt.o ./libjpeg/jfdctfst.o ./libjpeg/jfdctint.o ./libjpeg/jidctflt.o ./libjpeg/jidctfst.o ./libjpeg/jidctint.o ./libjpeg/jidctred.o ./libjpeg/jmemmgr.o ./libjpeg/jmemnobs.o ./libjpeg/jquant1.o ./libjpeg/jquant2.o ./libjpeg/jutils.o ./libpng/png.o ./libpng/pngerror.o ./libpng/pnggccrd.o ./libpng/pngget.o ./libpng/pngmem.o ./libpng/pngpread.o ./libpng/pngread.o ./libpng/pngrio.o ./libpng/pngrtran.o ./libpng/pngrutil.o ./libpng/pngset.o ./libpng/pngtrans.o ./libpng/pngvcrd.o ./libpng/pngwio.o ./libpng/pngwrite.o ./libpng/pngwtran.o ./libpng/pngwutil.o ./SOIL/image_DXT.o ./SOIL/SOIL.o ./SOIL/stb_image_aug.o ./zlib/adler32.o ./zlib/compress.o ./zlib/crc32.o ./zlib/deflate.o ./zlib/inffast.o ./zlib/inflate.o ./zlib/inftrees.o ./zlib/trees.o ./zlib/uncompr.o ./zlib/zutil.o -lfreetype -lX11 -lGL
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Graphics'
make[2]: Entering directory `/root/SFML-1.6/src/SFML/Audio'
g++ -o AudioDevice.o -c AudioDevice.cpp -W -Wall -pedantic -I../../../include -I../../ -O2 -DNDEBUG -fPIC
In file included from ../../SFML/Audio/AudioDevice.hpp:31,
                 from AudioDevice.cpp:28:
../../SFML/Audio/OpenAL.hpp:37:19: error: AL/al.h: No such file or directory
../../SFML/Audio/OpenAL.hpp:38:20: error: AL/alc.h: No such file or directory
In file included from ../../SFML/Audio/AudioDevice.hpp:31,
                 from AudioDevice.cpp:28:
../../SFML/Audio/OpenAL.hpp: In function ‘void sf::priv::ALCheckError(const std::string&, unsigned int)’:
../../SFML/Audio/OpenAL.hpp:74: error: ‘ALenum’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:74: error: expected `;' before ‘ErrorCode’
../../SFML/Audio/OpenAL.hpp:76: error: ‘ErrorCode’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:76: error: ‘AL_NO_ERROR’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:83: error: ‘AL_INVALID_NAME’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:90: error: ‘AL_INVALID_ENUM’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:97: error: ‘AL_INVALID_VALUE’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:104: error: ‘AL_INVALID_OPERATION’ was not declared in this scope
../../SFML/Audio/OpenAL.hpp:111: error: ‘AL_OUT_OF_MEMORY’ was not declared in this scope
In file included from AudioDevice.cpp:28:
../../SFML/Audio/AudioDevice.hpp: At global scope:
../../SFML/Audio/AudioDevice.hpp:78: error: ISO C++ forbids declaration of ‘ALCdevice’ with no type
../../SFML/Audio/AudioDevice.hpp:78: error: expected ‘;’ before ‘*’ token
../../SFML/Audio/AudioDevice.hpp:88: error: ‘ALenum’ does not name a type
../../SFML/Audio/AudioDevice.hpp:112: error: ISO C++ forbids declaration of ‘ALCdevice’ with no type
../../SFML/Audio/AudioDevice.hpp:112: error: expected ‘;’ before ‘*’ token
../../SFML/Audio/AudioDevice.hpp:113: error: ISO C++ forbids declaration of ‘ALCcontext’ with no type
../../SFML/Audio/AudioDevice.hpp:113: error: expected ‘;’ before ‘*’ token
AudioDevice.cpp: In constructor ‘sf::priv::AudioDevice::AudioDevice()’:
AudioDevice.cpp:52: error: ‘myDevice’ was not declared in this scope
AudioDevice.cpp:52: error: ‘alcOpenDevice’ was not declared in this scope
AudioDevice.cpp:57: error: ‘myContext’ was not declared in this scope
AudioDevice.cpp:57: error: ‘alcCreateContext’ was not declared in this scope
AudioDevice.cpp:62: error: ‘alcMakeContextCurrent’ was not declared in this scope
AudioDevice.cpp: In destructor ‘sf::priv::AudioDevice::~AudioDevice()’:
AudioDevice.cpp:86: error: ‘alcMakeContextCurrent’ was not declared in this scope
AudioDevice.cpp:87: error: ‘myContext’ was not declared in this scope
AudioDevice.cpp:88: error: ‘alcDestroyContext’ was not declared in this scope
AudioDevice.cpp:91: error: ‘myDevice’ was not declared in this scope
AudioDevice.cpp:92: error: ‘alcCloseDevice’ was not declared in this scope
AudioDevice.cpp: At global scope:
AudioDevice.cpp:143: error: expected constructor, destructor, or type conversion before ‘*’ token
AudioDevice.cpp:152: error: ‘ALenum’ does not name a type
make[2]: *** [AudioDevice.o] Error 1
make[2]: Leaving directory `/root/SFML-1.6/src/SFML/Audio'
make[1]: *** [sfml-audio] Error 2
make[1]: Leaving directory `/root/SFML-1.6/src/SFML'
make: *** [sfml] Error 2
root@bt:~/SFML-1.6#  

Like there is a bug in AudioDevice.cpp??
Please tell me how to solve this problem.

Thanks in advance!

3
General / Good Collision detection technique?
« on: April 19, 2011, 03:20:20 pm »
Hi,

I was creating some sort of game and I got a problem with my collision detection technique. Here is how I check the collision:
Code: [Select]

bool f_CheckCollision(c_Object A, c_Object B)
{
float leftA, leftB;
float rightA, rightB;
float topA, topB;
float bottomA, bottomB;
leftA = A.x;
leftB = B.x;
rightA = A.x + A.w;
rightB = B.x + B.w;
topA = A.y;
topB = B.y;
bottomA = A.y + A.h;
bottomB = B.y + B.h;
//If any of the sides from A are outside of B
    if( bottomA <= topB )
    {
        return false;
    }
   
    if( topA >= bottomB )
    {
        return false;
    }
   
    if( rightA <= leftB )
    {
        return false;
    }
   
    if( leftA >= rightB )
    {
        return false;
    }
   
    //If none of the sides from A are outside B
    return true;
}


It works ok If my object goes straight on X, or Y but when I press two arrows like UP and DOWN and my object goes trough the wall.
So is there a better way of checking collision between two objects but does not use much of CPU?

Thanks in advance!

4
Graphics / Access Violation Problem
« on: April 16, 2011, 02:08:19 am »
Fixed... :lol: It was set to Debug and when I set it to Release than it worked OK.

5
Graphics / Access Violation Problem
« on: April 16, 2011, 01:35:52 am »
I also have SFML 1.6, Using Visual C++ 2008 Express

6
Graphics / Access Violation Problem
« on: April 16, 2011, 12:16:42 am »
Hi,

I'm new here I've started to learn SFML and now I've encountered a problem that I don't know how to solve?

Code: [Select]

First-chance exception at 0xeeffee01 in SFML_Test.exe: 0xC0000005: Access violation.
Unhandled exception at 0xeeffee01 in SFML_Test.exe: 0xC0000005: Access violation.


Here is the code of my app:
Code: [Select]

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
//-------------------------------------------------------------------------------------------------------------------
#pragma comment(lib,"sfml-system-s.lib")
#pragma comment(lib,"sfml-window-s.lib")
#pragma comment(lib,"sfml-graphics-s.lib")
//-------------------------------------------------------------------------------------------------------------------
using namespace std;
//-------------------------------------------------------------------------------------------------------------------
sf::RenderWindow App;
sf::Event Event;
sf::Clock Clock;
//-------------------------------------------------------------------------------------------------------------------
const float Speed = 50.f;
//-------------------------------------------------------------------------------------------------------------------
float x = 0.f;
float y = 0.f;
float rot = 0.f;
float zaFPS = 0.f;
float FPS = 0.f;
//-------------------------------------------------------------------------------------------------------------------
void f_Clock();
void f_Render();
void f_DrawAll();
void f_HandleEvents();
void f_Init();
//-------------------------------------------------------------------------------------------------------------------
void f_Clock()
{
zaFPS = Clock.GetElapsedTime();
FPS = 1.f / Clock.GetElapsedTime();
Clock.Reset();
}
//-------------------------------------------------------------------------------------------------------------------
void f_Render()
{
App.Display();
}
//-------------------------------------------------------------------------------------------------------------------
void f_DrawAll()
{
App.Clear(sf::Color(200, 0, 0));
}
//-------------------------------------------------------------------------------------------------------------------
void f_HandleEvents()
{
while(App.GetEvent(Event))
{
// Window closed
        if (Event.Type == sf::Event::Closed)
            App.Close();

        // Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            App.Close();

}

if( App.GetInput().IsKeyDown(sf::Key::Left) ) x -= Speed * zaFPS; // LEVO
if( App.GetInput().IsKeyDown(sf::Key::Right) ) x += Speed * zaFPS;        // DESNO
if( App.GetInput().IsKeyDown(sf::Key::Up) ) y += Speed * zaFPS; // GORE
if( App.GetInput().IsKeyDown(sf::Key::Down) ) y -= Speed * zaFPS; // DOLE

}
//-------------------------------------------------------------------------------------------------------------------
void f_Init()
{
App.Create(sf::VideoMode(800, 600, 32), "SFML Window");
App.SetFramerateLimit(60);

}
//-------------------------------------------------------------------------------------------------------------------
int main()
{
f_Init();

while(App.IsOpened())
{
f_Clock();
f_HandleEvents();

cout << "X: " << x << "  Y: " << y << " FPS: " << FPS << endl;
f_DrawAll();
f_Render();
}
return 0;
}
//-------------------------------------------------------------------------------------------------------------------


I get the problem above when my app reaches the f_DrawAll() and tries to execute App.Clear(sf::Color(200, 0, 0)); .

So any idea how to fix this problem?

Best Regards!

Pages: [1]
anything