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.


Topics - Azaral

Pages: [1] 2
1
General discussions / Baffled by problem and need help
« on: March 27, 2014, 07:44:03 pm »
OK, so I have just the strangest problem and I can't figure out why it is happening.

I have this bit of code, which makes the error.

bool nextLayerBlocked = false;

        for( unsigned int i = 0; i < interactiveElements.size() && nextLayerBlocked == false; ++i )
        {
            std::cout << "Processing layer " << i <<" of gui" << std::endl;

            for( unsigned int j = 0; j < interactiveElements[i].size(); ++j )
            {
                std::cout << "Processing element " << j << " of layer " << i << std::endl;

                interactiveElements[i][j]->HandleInput( userInput );

                if( interactiveElements[i][j]->IsLayerBlocking() == true )
                {
                    std::cout << "Next Layer is blocked" << std::endl;

                    nextLayerBlocked = true;
                }

                if( interactiveElements[i][j]->IsBlocking() == true )
                {
                    std::cout << "Element is blocking" << std::endl;

                    activeElement = interactiveElements[i][j];

                    j = interactiveElements[i].size();
                    i = interactiveElements.size();
                }

                std::cout << "j = " << j << " i = " << i << std::endl;
            }
        }
 

Now, when ran in the debugger, it works exactly as expected. When not run in debugger, however, it crashes. What happens not in the debugger is that when an element blocks and it sets j and i to be equal to the sizes to exit the loop, the for loops ignore their check! The cout's report the numbers as being 1 larger than they are at the end, like the loops increase them by 1 and say, yup, these numbers are still smaller than the vector size. This in turn causes a segment fault.

What baffles me is the fact that it works fine when run through the debugger, but then fails when not. I don't understand. It's probably something small and stupid, but I can't find it.

2
Graphics / How to give a shader an array of values?
« on: February 18, 2014, 06:40:32 am »
A friend of mine and I are making a program for fun, and it has fallen to me to write a shader to display the results. The shader is a fragment shader. In order to do what it needs to do, I need to get two arrays of float values. How can I use an array inside a shader and how can I pass this array from the c++ program into the shader program?

I've been looking, but the results haven't been helping me much. They are also in the context of just opengl and glsl, and I'm not sure how that would apply to the SFML context.

3
General discussions / Class for extremely big, or small, numbers
« on: February 06, 2014, 09:52:36 pm »
Is there a class that allows for any number of digits before and after the decimal point for C++? Something that will allow me to have numbers that are bigger or smaller than what I can get with the standard data types.

4
General discussions / Unit Testing
« on: February 04, 2014, 03:40:30 am »
I just recently came across this. I only have a vague idea of what it is. I have no idea how to actually do it, but I would like to give it a try, but I have no idea where to being or even what is really going on with one. Any kind of information you could give me would be great.

5
SFML projects / My game project - The Merging
« on: January 31, 2014, 04:51:32 pm »
I had originally typed a big thing here and was going to almost have this thread be like a blog, but then I decided I would just start a blog for it lol.

Here is the first post of that blog. Many will come in rapid succession I think (so long as I keep up with it) while it plays catch up with what has already been done.

http://themerging.blogspot.com/

6
General / Passing new and storing in a smart pointer safe?
« on: January 23, 2014, 07:02:14 pm »
Is this safe or should I pass std::unique_ptr instead of using new?


void Function( Object* object )
{
     myObjects.push_back( std::unique_ptr< Object >( object ); //myObjects is a vector of std::unique_ptr< Object >
}

Function( new object );

 

Or would this be better?


void Function( std::unique_ptr< Object > object )
{
     myObjects.push_back( std::move( object ) ); //myObjects is a vector of std::unique_ptr< Object >
}

Function( std::unique_ptr< Object >( new object ) );

 

I ask because I just started making use of smart pointers and want to make sure I'm doing it right.

7
General discussions / #pragma once vs #ifndef - Which is better?
« on: January 23, 2014, 03:02:33 pm »
What is the difference between #pragma once and #ifndef guards? Which is better to use and why?

8
Network / Security Measures
« on: January 22, 2014, 12:42:56 am »
My game will have players connecting to a central server which will store data for the player and will be the hub for the players to connect to when they are looking to join a game. After the game starts the players will no longer have connection to the central server and the game will commence with the players being the server for the game. What sort of security measures should be/need to be used?

9
Network / Trouble with socket selector[Solved]
« on: January 14, 2014, 01:42:27 am »
So I'm trying to learn how to use the network package by making a simple chat program. The issue I'm having is using the socket selector. I followed the example given exactly, with some added cout's to see whats going on inside of it in the console. The issue I'm having is the server will act as expected, it gets to the if( selector.wait() ) part and the function blocks like it is suppose to. I know this because I have a text output right before that line and it is inside an infinite loop. However, once the first client connects to the server, the selector.wait() function fails to block. I know this because the server console window gets spammed with my message. It also never receives anything from the clients because I have an output on the server such that no matter what happens inside the if something will get pasted to the console screen.

There must be something I'm missing. I can't find it.

I'm running the test by connecting to local host if that matters.

Any help would be greatly appreciated.

10
General / Weird error - SFML2.0
« on: May 14, 2013, 06:59:18 pm »
So, I'm getting this weird error. I have a loop that runs the program and I exit the loop by setting a bool to false when escape is pressed. However, when I move my mouse to a general location, located near the upper left hand corner of the screen the program will exit on its' own. It doesn't throw any error message in release or in debug mode. If I take out the key checking part, it does not occur.

I'm using SFML 2.0 , using visual studio 2010 express, windows 7 OS

11
General / Component based entity system
« on: December 28, 2012, 05:44:10 pm »
I've read a lot about a component based entity system and the philosophy of it and that all sounds great. What I haven't read much about, however, is actually implementing one.

All that I've managed to find is basically general musings and such or a basic overview of how to program one.

From what I've read, an entity is nothing more than a unique ID number which then has components tied to it. Components are nothing more than data for a system to do things with. This is so you only have one instance of all your logic code running instead of one instance of the code for each instance of your entities if you go the object oriented route (each entity is it's own class, probably derived from a couple of base classes).

The systems then go through all entities and run logic based on the components the entities have. If the entity has no component the system cares about then the system doesn't care about the entity.

The advantage is suppose to be increased flexibility in your entity creations and less overhead whatever from having only one instance of your logic code being present in the game.

I've been pondering it off and on on how to actually program something like this but I haven't made much headway. I'm just wondering if anyone here can provide any insight. This is something I would like to do for my game down the line (once i get done making this dang fangled level editor for it). Since it's a major component of the game (it only controls almost everything) i figured I'd get a head start on figuring it out whilst I piddle away at my editor. If this post makes no damned sense I'm sorry lol. Very tired today.

12
General / Iterating through a list of pointers
« on: December 23, 2012, 05:20:28 pm »
I have this list:

std::list<ButtonBase*> buttons;

I want to iterate through it.

I have:

std::list<ButtonBase*>::iterator currentButton = buttons.begin();

It however tells me that there is no suitable conversion function for this. This is pretty straight forward, what am I missing?

13
Graphics / Sprites not displaying properly
« on: December 21, 2012, 01:58:29 am »
I seem to have a problem getting sprites to display properly. The sprites know where they should be and their size, but they don't show the actual graphic. If I change the color to something not white, the box will show up, but the actual graphic won't. I'm trying to load .png images. What does this usually mean? If you need more info ask cause I'm stumped as to what is going wrong.

14
General / Deleting text
« on: December 11, 2012, 06:41:10 pm »
So, I'm trying to make a simple text field for user to type information, names etc. I can get the text input just find and display it just fine, however, what I haven't managed to do so far is to get the ability to backspace to work. Some help would be appreciated.

15
Network / Overloading insertion and extraction operator troubles.
« on: November 18, 2012, 04:34:38 pm »
I made a class to store commands to be sent from the player to the server. I overloaded the insertion and extraction operators, but it is giving me linking errors. It has been a while since I overloaded an operator so I might be doing it wrong, which I am imaging is the case. Any help would be greatly appreciated.

Here is the file that overloads the operators. It is Visual Studio 2010 Express using SFML 1.6.
Code: [Select]
#pragma once

#include <SFML\Network.hpp>

class CommandFlags
{

public:

bool moveForward;
bool moveBackward;
bool moveLeft;
bool moveRight;

bool shoot;
bool unshoot;

sf::Uint16 mouseX;
sf::Uint16 mouseY;

CommandFlags();
CommandFlags(const CommandFlags &source);
};

sf::Packet &operator >>(sf::Packet &packet, CommandFlags getFlags)
{
return packet >> getFlags.mouseX >> getFlags.mouseY >> getFlags.moveBackward >> getFlags.moveForward >> getFlags.moveLeft >> getFlags.moveRight >> getFlags.shoot >> getFlags.unshoot;
}

sf::Packet &operator <<(sf::Packet &packet, CommandFlags sendFlags)
{
return packet << sendFlags.mouseX << sendFlags.mouseY << sendFlags.moveBackward << sendFlags.moveForward << sendFlags.moveLeft << sendFlags.moveRight << sendFlags.shoot << sendFlags.unshoot;
}

Here is the error I get:

Code: [Select]
1>server-player.obj : error LNK2005: "class sf::Packet & __cdecl operator<<(class sf::Packet &,class CommandFlags)" (??6@YAAAVPacket@sf@@AAV01@VCommandFlags@@@Z) already defined in commandflags.obj

Here is the two files for that class:
Code: [Select]
#include "server-player.h"

Player::Player()
{

}

Player::Player(sf::IPAddress setIP, int setPort, std::string setName)
{
port = setPort;
ip = setIP;
name = setName;
}

sf::IPAddress Player::GetIP()
{
return ip;
}

std::string Player::GetName()
{
return name;
}

void Player::SetName(std::string setName)
{
name = setName;
}

void Player::Fill(sf::IPAddress playerIP, std::string playerName, unsigned short int playerPort)
{
ip = playerIP;
name = playerName;
port = playerPort;
}

bool Player::IsOccupied()
{
return slotOccupied;
}

void Player::SetCommandFlags(CommandFlags flags)
{
playership->SetCommands(flags);
}

Code: [Select]
#pragma once

#include <string>
#include <queue>

#include <SFML/Network.hpp>

#include "commandflags.h"
#include "server-ship.h"

class Player
{

private:

sf::IPAddress ip;

unsigned short int port;

std::string name;

bool slotOccupied;

ServerShip *playership;

public:

Player();
Player(sf::IPAddress setIP, int setPort, std::string setName);

sf::IPAddress GetIP();

std::string GetName();

void SetName(std::string setName);

void Fill(sf::IPAddress playerIP, std::string playerName, unsigned short int playerPort);

bool IsOccupied();

void SetCommandFlags(CommandFlags flags);

void SetPlayerShip(ServerShip *setShip);
ServerShip* GetPlayerShip();
};

Pages: [1] 2