Code Search for Developers
 
 
  

connectstate.h from FreePop at Krugle


Show connectstate.h syntax highlighted

/***************************************************************************
                           connectstate.h
                           -------------------
    begin                : Wed Feb 2 2005
    copyright            : (C) 2005 by Brendon Lloyd Higgins
    email                : bh_doc@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CONNECTSTATE_H_INCLUDED
#define CONNECTSTATE_H_INCLUDED

#include <clientstate.h>
#include <ClanLib/network.h>

class LoadState;
class PlayerClient;

/**
 * List type containing the players.
 */
typedef std::list<PlayerClient*> PlayerList;

/**
 * Handles connection and handshake, player info, and waiting for the server to
 * start.
 */
class ConnectState: public ClientState {
public:
    /**
     * Constructor.
     */
    ConnectState(const CL_IPAddress& serv);

    /**
     * Destructor.
     */
    virtual ~ConnectState();

    virtual ClientState* go(Client* client);

private:
    /**
     * Handle a server welcome.
     */
    void onNetHandshake(CL_NetStream& stream);

    /**
     * Handle the game start.
     */
    void onStart(CL_NetStream& stream);

    /**
     * Handle unexpected disconnect.
     */
    void onDisconnect(CL_NetComputer& computer);

    /**
     * Admin message recieved.
     */
    void onAdmin(CL_NetPacket& packet, CL_NetComputer &computer);

    /**
     * Create a player.
     */
    void onPlayerCreate(CL_InputSource& is);

    /**
     * Process a player message.
     */
    void onPlayerMessage(CL_NetPacket& p);

    /**
     * Remove a player from the list.
     */
    void onPlayerRemove(CL_NetPacket& p);

    /**
     * The address and port of the server.
     */
    CL_IPAddress serverIP;

    /**
     * The netsession.
     */
    CL_NetSession* netsession;

    /**
     * The server.
     */
    CL_NetComputer server;

    /**
     * Slot used to signal the next step in game state construction.
     * The first step is handshaking. The second step is game start.
     */
    CL_Slot* nextSlot;

    /**
     * The list of players.
     */
    PlayerList* players;

    /**
     * The local player.
     */
    PlayerClient* me;

    /**
     * States.
     */
    enum State {
        AWAIT_HANDSHAKE,
        AWAIT_START,
        FAIL
    };

    /**
     * Current state.
     */
    State state;

    /**
     * The next state class to come after this one.
     */
    LoadState* next;
};

#endif /* ndef CONNECTSTATE_H_INCLUDED */




See more files for this project here

FreePop

FreePop is a multi-platform tile-based game based on the great old game Populous 2 by Bullfrog Productions Ltd., but much improved.

Project homepage: http://sourceforge.net/projects/freepop
Programming language(s): C++
License: other

  Makefile.am
  client.cpp
  client.h
  clientmisc.cpp
  clientmisc.h
  clientstate.cpp
  clientstate.h
  connectstate.cpp
  connectstate.h
  cropsclient.cpp
  cropsclient.h
  entityclient.cpp
  entityclient.h
  entityclientfactory.cpp
  entityclientfactory.h
  firecolumnclient.cpp
  firecolumnclient.h
  gamestate.cpp
  gamestate.h
  loadstate.cpp
  loadstate.h
  mapclient.cpp
  mapclient.h
  maptileclient.cpp
  maptileclient.h
  messagebox.cpp
  messagebox.h
  oversprite.cpp
  oversprite.h
  paintable.cpp
  paintable.h
  pausefader.cpp
  pausefader.h
  peepclient.cpp
  peepclient.h
  peepmagnetclient.cpp
  peepmagnetclient.h
  playerclient.cpp
  playerclient.h
  playeroptionsdialog.cpp
  playeroptionsdialog.h
  rockclient.cpp
  rockclient.h
  swampclient.cpp
  swampclient.h
  townclient.cpp
  townclient.h
  treeclient.cpp
  treeclient.h
  worldclient.cpp
  worldclient.h