Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/network_game_manager.cc @ 7984

Last change on this file since 7984 was 7984, checked in by rennerc, 18 years ago

new NetworkGameManager

File size: 2.5 KB
RevLine 
[6067]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Benjamin Wuest
13   co-programmer: ...
14*/
15
16
17/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module
18   For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
19*/
20#define DEBUG_MODULE_NETWORK
21
[7193]22#include "util/loading/factory.h"
[7349]23#include "state.h"
24#include "class_list.h"
25
[6341]26#include "network_stream.h"
[7349]27#include "shared_network_data.h"
[6341]28#include "converter.h"
[7954]29#include "message_manager.h"
[6341]30
[6498]31#include "playable.h"
32#include "player.h"
[6424]33
[7349]34#include "game_world.h"
[6424]35
[7984]36#include "game_rules.h"
37#include "network_game_rules.h"
38
[6116]39#include "network_game_manager.h"
[6067]40
41
42/* using namespace std is default, this needs to be here */
43using namespace std;
44
[6341]45NetworkGameManager* NetworkGameManager::singletonRef = NULL;
46
[6067]47/*!
48 * Standard constructor
49 */
[6116]50NetworkGameManager::NetworkGameManager()
[6695]51  : Synchronizeable()
[6067]52{
[6341]53  PRINTF(0)("START\n");
54
[6067]55  /* set the class id for the base object */
[6341]56  this->setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager");
57
[6695]58  this->setSynchronized(true);
[6067]59}
60
61/*!
62 * Standard destructor
63 */
[6116]64NetworkGameManager::~NetworkGameManager()
[6067]65{
66}
67
[6341]68
[7984]69/**
70 * insert new player into game
71 * @param userId
72 * @return
[6067]73 */
[7984]74bool NetworkGameManager::signalNewPlayer( int userId )
[6067]75{
[7984]76  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
[7954]77 
[7984]78  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
[7954]79 
[7984]80  int team = rules.getTeamForNewUser();
81  ClassID playableClassId = rules.getPlayableClassId( team );
82  std::string playableModel = rules.getPlayableModelFileName( team, playableClassId );
[7954]83 
[7984]84  BaseObject * bo = Factory::fabricate( playableClassId );
[7954]85 
[7984]86  assert( bo->isA( CL_PLAYABLE ) );
[7954]87 
[7984]88  Playable & playable = *(dynamic_cast<Playable*>(bo));
89 
90  playable.loadModel( playableModel );
91 
92  PlayerStats * stats = rules.getNewPlayerStats( userId );
93 
94  stats->setTeamId( team );
95  stats->setPlayableClassId( playableClassId );
96  stats->setPlayableUniqueId( playable.getUniqueID() );
97  stats->setModelFileName( playableModel );
[6341]98}
99
100
[6695]101/**
[7984]102 * remove player from game
103 * @param userID
104 * @return
[6695]105 */
[7984]106bool NetworkGameManager::signalLeftPlayer(int userID)
[6695]107{
108}
109
110
[7954]111
112
[6341]113
114
115
Note: See TracBrowser for help on using the repository browser.