clients can see which setups are made on the server. ( work in progress !)
menu gfx-components can be set editable/non editable now + in addition fixed several memory problems and FOW in scenarios ...)
This commit is contained in:
parent
21a1932bbb
commit
06660e3a17
|
@ -35,6 +35,7 @@ const float GraphicComponent::fadeSpeed= 0.01f;
|
|||
|
||||
GraphicComponent::GraphicComponent(){
|
||||
enabled= true;
|
||||
editable= true;
|
||||
}
|
||||
|
||||
void GraphicComponent::init(int x, int y, int w, int h){
|
||||
|
@ -133,6 +134,12 @@ void GraphicListBox::setSelectedItemIndex(int index){
|
|||
setText(getSelectedItem());
|
||||
}
|
||||
|
||||
void GraphicListBox::setEditable(bool editable){
|
||||
graphButton1.setEditable(editable);
|
||||
graphButton2.setEditable(editable);
|
||||
editable=true;
|
||||
}
|
||||
|
||||
void GraphicListBox::setSelectedItem(string item){
|
||||
vector<string>::iterator iter;
|
||||
|
||||
|
|
|
@ -0,0 +1,186 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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 _GLEST_GAME_GRAPHCOMPONENT_H_
|
||||
#define _GLEST_GAME_GRAPHCOMPONENT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "font.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
using Shared::Graphics::Font2D;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
// ===========================================================
|
||||
// class GraphicComponent
|
||||
//
|
||||
// OpenGL renderer GUI components
|
||||
// ===========================================================
|
||||
|
||||
class GraphicComponent{
|
||||
public:
|
||||
static const float animSpeed;
|
||||
static const float fadeSpeed;
|
||||
|
||||
protected:
|
||||
int x, y, w, h;
|
||||
string text;
|
||||
const Font2D *font;
|
||||
bool enabled;
|
||||
bool editable;
|
||||
|
||||
static float anim;
|
||||
static float fade;
|
||||
|
||||
public:
|
||||
GraphicComponent();
|
||||
virtual ~GraphicComponent(){}
|
||||
|
||||
void init(int x, int y, int w, int h);
|
||||
|
||||
int getX() const {return x;}
|
||||
int getY() const {return y;}
|
||||
int getW() const {return w;}
|
||||
int getH() const {return h;}
|
||||
const string &getText() const {return text;}
|
||||
const Font2D *getFont() const {return font;}
|
||||
bool getEnabled() const {return enabled;}
|
||||
bool getEditable() const {return editable;}
|
||||
|
||||
void setX(int x) {this->x= x;}
|
||||
void setY(int y) {this->y= y;}
|
||||
void setText(const string &text) {this->text= text;}
|
||||
void setFont(const Font2D *font) {this->font= font;}
|
||||
void setEnabled(bool enabled) {this->enabled= enabled;}
|
||||
void setEditable(bool editable) {this->editable= editable;}
|
||||
|
||||
virtual bool mouseMove(int x, int y);
|
||||
virtual bool mouseClick(int x, int y);
|
||||
|
||||
static void update();
|
||||
static void resetFade();
|
||||
static float getAnim() {return anim;}
|
||||
static float getFade() {return fade;}
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
// class GraphicLabel
|
||||
// ===========================================================
|
||||
|
||||
class GraphicLabel: public GraphicComponent{
|
||||
public:
|
||||
static const int defH;
|
||||
static const int defW;
|
||||
|
||||
private:
|
||||
bool centered;
|
||||
|
||||
public:
|
||||
void init(int x, int y, int w=defW, int h=defH, bool centered= false);
|
||||
|
||||
bool getCentered() const {return centered;}
|
||||
|
||||
void setCentered(bool centered) {this->centered= centered;}
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
// class GraphicButton
|
||||
// ===========================================================
|
||||
|
||||
class GraphicButton: public GraphicComponent{
|
||||
public:
|
||||
static const int defH;
|
||||
static const int defW;
|
||||
|
||||
private:
|
||||
bool lighted;
|
||||
|
||||
public:
|
||||
void init(int x, int y, int w=defW, int h=defH);
|
||||
|
||||
bool getLighted() const {return lighted;}
|
||||
|
||||
void setLighted(bool lighted) {this->lighted= lighted;}
|
||||
virtual bool mouseMove(int x, int y);
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
// class GraphicListBox
|
||||
// ===========================================================
|
||||
|
||||
class GraphicListBox: public GraphicComponent{
|
||||
public:
|
||||
static const int defH;
|
||||
static const int defW;
|
||||
|
||||
private:
|
||||
GraphicButton graphButton1, graphButton2;
|
||||
vector<string> items;
|
||||
int selectedItemIndex;
|
||||
|
||||
public:
|
||||
void init(int x, int y, int w=defW, int h=defH);
|
||||
|
||||
int getItemCount() const {return items.size();}
|
||||
int getSelectedItemIndex() const {return selectedItemIndex;}
|
||||
string getSelectedItem() const {return items[selectedItemIndex];}
|
||||
const GraphicButton *getButton1() const {return &graphButton1;}
|
||||
const GraphicButton *getButton2() const {return &graphButton2;}
|
||||
|
||||
void pushBackItem(string item);
|
||||
void setItems(const vector<string> &items);
|
||||
void setSelectedItemIndex(int index);
|
||||
void setSelectedItem(string item);
|
||||
void setEditable(bool editable);
|
||||
|
||||
virtual bool mouseMove(int x, int y);
|
||||
virtual bool mouseClick(int x, int y);
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
// class GraphicMessageBox
|
||||
// ===========================================================
|
||||
|
||||
class GraphicMessageBox: public GraphicComponent{
|
||||
public:
|
||||
static const int defH;
|
||||
static const int defW;
|
||||
|
||||
private:
|
||||
GraphicButton button1;
|
||||
GraphicButton button2;
|
||||
int buttonCount;
|
||||
string header;
|
||||
|
||||
public:
|
||||
void init(const string &button1Str, const string &button2Str);
|
||||
void init(const string &button1Str);
|
||||
|
||||
int getButtonCount() const {return buttonCount;}
|
||||
const GraphicButton *getButton1() const {return &button1;}
|
||||
const GraphicButton *getButton2() const {return &button2;}
|
||||
string getHeader() const {return header;}
|
||||
|
||||
void setHeader(string header) {this->header= header;}
|
||||
|
||||
virtual bool mouseMove(int x, int y);
|
||||
virtual bool mouseClick(int x, int y);
|
||||
bool mouseClick(int x, int y, int &clickedButton);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -46,7 +46,9 @@ private:
|
|||
public:
|
||||
|
||||
|
||||
GameSettings() { }
|
||||
GameSettings() {
|
||||
fogOfWar = true;
|
||||
}
|
||||
|
||||
// default copy constructor will do fine, and will maintain itself ;)
|
||||
|
||||
|
|
|
@ -960,6 +960,8 @@ void Renderer::renderButton(const GraphicButton *button){
|
|||
int h= button->getH();
|
||||
int w= button->getW();
|
||||
|
||||
const Vec3f disabledTextColor= Vec3f(0.25f,0.25f,0.25f);
|
||||
|
||||
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT);
|
||||
|
||||
//background
|
||||
|
@ -996,7 +998,7 @@ void Renderer::renderButton(const GraphicButton *button){
|
|||
float anim= GraphicComponent::getAnim();
|
||||
if(anim>0.5f) anim= 1.f-anim;
|
||||
|
||||
if(button->getLighted()){
|
||||
if(button->getLighted() && button->getEditable()){
|
||||
const int lightSize= 0;
|
||||
const Vec4f color1= Vec4f(1.f, 1.f, 1.f, 0.1f+anim*0.5f);
|
||||
const Vec4f color2= Vec4f(1.f, 1.f, 1.f, 0.3f+anim);
|
||||
|
@ -1029,9 +1031,19 @@ void Renderer::renderButton(const GraphicButton *button){
|
|||
|
||||
Vec2i textPos= Vec2i(x+w/2, y+h/2);
|
||||
|
||||
renderText(
|
||||
button->getText(), button->getFont(), GraphicButton::getFade(),
|
||||
x+w/2, y+h/2, true);
|
||||
if(button->getEditable()){
|
||||
renderText(
|
||||
button->getText(), button->getFont(), GraphicButton::getFade(),
|
||||
x+w/2, y+h/2, true);
|
||||
}
|
||||
else {
|
||||
renderText(
|
||||
button->getText(), button->getFont(),disabledTextColor,
|
||||
x+w/2, y+h/2, true);
|
||||
// renderText(
|
||||
// button->getText(), button->getFont(), 0.2f,
|
||||
// x+w/2, y+h/2, true);
|
||||
}
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace Glest{ namespace Game{
|
|||
// =====================================================
|
||||
|
||||
// ===================== PUBLIC ========================
|
||||
MenuState *oldstate=NULL;
|
||||
|
||||
MainMenu::MainMenu(Program *program):
|
||||
ProgramState(program)
|
||||
|
@ -154,10 +155,10 @@ void MainMenu::keyPress(char c){
|
|||
}
|
||||
|
||||
void MainMenu::setState(MenuState *state){
|
||||
delete this->state;
|
||||
if(oldstate!=NULL) delete oldstate;
|
||||
MenuState *oldstate=this->state;
|
||||
this->state= state;
|
||||
GraphicComponent::resetFade();
|
||||
|
||||
menuBackground.setTargetCamera(state->getCamera());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,630 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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
|
||||
// ==============================================================
|
||||
|
||||
#include "menu_state_connected_game.h"
|
||||
|
||||
#include "menu_state_join_game.h"
|
||||
#include "renderer.h"
|
||||
#include "sound_renderer.h"
|
||||
#include "core_data.h"
|
||||
#include "config.h"
|
||||
#include "menu_state_new_game.h"
|
||||
#include "metrics.h"
|
||||
#include "network_manager.h"
|
||||
#include "network_message.h"
|
||||
#include "client_interface.h"
|
||||
#include "conversion.h"
|
||||
#include "socket.h"
|
||||
#include "game.h"
|
||||
#include <algorithm>
|
||||
#include <time.h>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
||||
struct FormatString {
|
||||
void operator()(string &s) {
|
||||
s = formatString(s);
|
||||
}
|
||||
};
|
||||
|
||||
string currentFactionName="";
|
||||
string currentMap="";
|
||||
// =====================================================
|
||||
// class MenuStateConnectedGame
|
||||
// =====================================================
|
||||
|
||||
MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots):
|
||||
MenuState(program, mainMenu, "join-game")
|
||||
{
|
||||
Lang &lang= Lang::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
Config &config = Config::getInstance();
|
||||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);;
|
||||
|
||||
vector<string> teamItems, controlItems, results;
|
||||
//state
|
||||
labelStatus.init(330, 700);
|
||||
labelStatus.setText("");
|
||||
|
||||
labelInfo.init(30, 700);
|
||||
labelInfo.setText("");
|
||||
|
||||
|
||||
|
||||
//create
|
||||
buttonDisconnect.init(350, 180, 125);
|
||||
buttonPlayNow.init(525, 180, 125);
|
||||
|
||||
//map listBox
|
||||
// put them all in a set, to weed out duplicates (gbm & mgm with same name)
|
||||
// will also ensure they are alphabetically listed (rather than how the OS provides them)
|
||||
listBoxMap.init(100, 260, 200);
|
||||
listBoxMap.setEditable(false);
|
||||
|
||||
//listBoxMap.setItems(results);
|
||||
labelMap.init(100, 290);
|
||||
labelMapInfo.init(100, 230, 200, 40);
|
||||
|
||||
|
||||
// fog - o - war
|
||||
// @350 ? 300 ?
|
||||
labelFogOfWar.init(350, 290, 100);
|
||||
listBoxFogOfWar.init(350, 260, 100);
|
||||
listBoxFogOfWar.pushBackItem(lang.get("Yes"));
|
||||
listBoxFogOfWar.pushBackItem(lang.get("No"));
|
||||
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||
listBoxFogOfWar.setEditable(false);
|
||||
|
||||
//tileset listBox
|
||||
listBoxTileset.init(500, 260, 150);
|
||||
listBoxTileset.setEditable(false);
|
||||
//listBoxTileset.setItems(results);
|
||||
labelTileset.init(500, 290);
|
||||
|
||||
//tech Tree listBox
|
||||
listBoxTechTree.init(700, 260, 150);
|
||||
listBoxTechTree.setEditable(false);
|
||||
//listBoxTechTree.setItems(results);
|
||||
labelTechTree.init(700, 290);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//list boxes
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
labelPlayers[i].init(100, 550-i*30);
|
||||
labelPlayers[i].setEditable(false);
|
||||
listBoxControls[i].init(200, 550-i*30);
|
||||
listBoxControls[i].setEditable(false);
|
||||
listBoxFactions[i].init(400, 550-i*30);
|
||||
listBoxFactions[i].setEditable(false);
|
||||
listBoxTeams[i].init(600, 550-i*30, 60);
|
||||
listBoxTeams[i].setEditable(false);
|
||||
labelNetStatus[i].init(700, 550-i*30, 60);
|
||||
}
|
||||
|
||||
labelControl.init(200, 600, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||
labelFaction.init(400, 600, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||
labelTeam.init(600, 600, 60, GraphicListBox::defH, true);
|
||||
|
||||
//texts
|
||||
buttonDisconnect.setText(lang.get("Return"));
|
||||
buttonPlayNow.setText(lang.get("PlayNow"));
|
||||
|
||||
controlItems.push_back(lang.get("Closed"));
|
||||
controlItems.push_back(lang.get("CpuEasy"));
|
||||
controlItems.push_back(lang.get("Cpu"));
|
||||
controlItems.push_back(lang.get("CpuUltra"));
|
||||
controlItems.push_back(lang.get("CpuMega"));
|
||||
controlItems.push_back(lang.get("Network"));
|
||||
controlItems.push_back(lang.get("Human"));
|
||||
teamItems.push_back("1");
|
||||
teamItems.push_back("2");
|
||||
teamItems.push_back("3");
|
||||
teamItems.push_back("4");
|
||||
teamItems.push_back("5");
|
||||
teamItems.push_back("6");
|
||||
teamItems.push_back("7");
|
||||
teamItems.push_back("8");
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
labelPlayers[i].setText(lang.get("Player")+" "+intToStr(i));
|
||||
listBoxTeams[i].setItems(teamItems);
|
||||
listBoxTeams[i].setSelectedItemIndex(i);
|
||||
listBoxControls[i].setItems(controlItems);
|
||||
labelNetStatus[i].setText("");
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
labelMap.setText(lang.get("Map"));
|
||||
labelFogOfWar.setText(lang.get("FogOfWar"));
|
||||
labelTileset.setText(lang.get("Tileset"));
|
||||
labelTechTree.setText(lang.get("TechTree"));
|
||||
labelControl.setText(lang.get("Control"));
|
||||
labelFaction.setText(lang.get("Faction"));
|
||||
labelTeam.setText(lang.get("Team"));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
//init controllers
|
||||
listBoxControls[0].setSelectedItemIndex(ctHuman);
|
||||
chatManager.init(&console, -1);
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
|
||||
if(buttonDisconnect.mouseClick(x,y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
if(clientInterface->getSocket() != NULL)
|
||||
{
|
||||
if(clientInterface->isConnected() == true)
|
||||
{
|
||||
string sQuitText = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + " has chosen to leave the game!";
|
||||
clientInterface->sendTextMessage(sQuitText,-1);
|
||||
}
|
||||
clientInterface->close();
|
||||
}
|
||||
clientInterface->reset();
|
||||
networkManager.end();
|
||||
currentFactionName="";
|
||||
currentMap="";
|
||||
mainMenu->setState(new MenuStateJoinGame(program, mainMenu));
|
||||
}
|
||||
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
soundRenderer.playFx(coreData.getClickSoundC());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(listBoxMap.mouseClick(x, y)){
|
||||
|
||||
}
|
||||
else if (listBoxFogOfWar.mouseClick(x, y)) {
|
||||
}
|
||||
else if(listBoxTileset.mouseClick(x, y)){
|
||||
}
|
||||
else if(listBoxTechTree.mouseClick(x, y)){
|
||||
//reloadFactions();
|
||||
|
||||
if(hasNetworkGameSettings() == true)
|
||||
{
|
||||
needToSetChangedGameSettings = true;
|
||||
lastSetChangedGameSettings = time(NULL);;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// for(int i=0; i<mapInfo.players; ++i)
|
||||
// {
|
||||
// //ensure thet only 1 human player is present
|
||||
// if(listBoxControls[i].mouseClick(x, y))
|
||||
// {
|
||||
// //look for human players
|
||||
// int humanIndex1= -1;
|
||||
// int humanIndex2= -1;
|
||||
// for(int j=0; j<GameConstants::maxPlayers; ++j){
|
||||
// ControlType ct= static_cast<ControlType>(listBoxControls[j].getSelectedItemIndex());
|
||||
// if(ct==ctHuman){
|
||||
// if(humanIndex1==-1){
|
||||
// humanIndex1= j;
|
||||
// }
|
||||
// else{
|
||||
// humanIndex2= j;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //no human
|
||||
// if(humanIndex1==-1 && humanIndex2==-1){
|
||||
// listBoxControls[i].setSelectedItemIndex(ctHuman);
|
||||
// }
|
||||
//
|
||||
// //2 humans
|
||||
// if(humanIndex1!=-1 && humanIndex2!=-1){
|
||||
// listBoxControls[humanIndex1==i? humanIndex2: humanIndex1].setSelectedItemIndex(ctClosed);
|
||||
// }
|
||||
//
|
||||
// if(hasNetworkGameSettings() == true)
|
||||
// {
|
||||
// needToSetChangedGameSettings = true;
|
||||
// lastSetChangedGameSettings = time(NULL);;
|
||||
// }
|
||||
// }
|
||||
// else if(listBoxFactions[i].mouseClick(x, y)){
|
||||
//
|
||||
// if(hasNetworkGameSettings() == true)
|
||||
// {
|
||||
// needToSetChangedGameSettings = true;
|
||||
// lastSetChangedGameSettings = time(NULL);;
|
||||
// }
|
||||
// }
|
||||
// else if(listBoxTeams[i].mouseClick(x, y))
|
||||
// {
|
||||
// if(hasNetworkGameSettings() == true)
|
||||
// {
|
||||
// needToSetChangedGameSettings = true;
|
||||
// lastSetChangedGameSettings = time(NULL);;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
|
||||
|
||||
buttonDisconnect.mouseMove(x, y);
|
||||
buttonPlayNow.mouseMove(x, y);
|
||||
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
listBoxControls[i].mouseMove(x, y);
|
||||
listBoxFactions[i].mouseMove(x, y);
|
||||
listBoxTeams[i].mouseMove(x, y);
|
||||
}
|
||||
listBoxMap.mouseMove(x, y);
|
||||
listBoxFogOfWar.mouseMove(x, y);
|
||||
listBoxTileset.mouseMove(x, y);
|
||||
listBoxTechTree.mouseMove(x, y);
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::render(){
|
||||
|
||||
try {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
int i;
|
||||
|
||||
renderer.renderButton(&buttonDisconnect);
|
||||
renderer.renderButton(&buttonPlayNow);
|
||||
|
||||
for(i=0; i<GameConstants::maxPlayers; ++i){
|
||||
renderer.renderLabel(&labelPlayers[i]);
|
||||
renderer.renderListBox(&listBoxControls[i]);
|
||||
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
|
||||
renderer.renderListBox(&listBoxFactions[i]);
|
||||
renderer.renderListBox(&listBoxTeams[i]);
|
||||
renderer.renderLabel(&labelNetStatus[i]);
|
||||
}
|
||||
}
|
||||
renderer.renderLabel(&labelStatus);
|
||||
renderer.renderLabel(&labelInfo);
|
||||
renderer.renderLabel(&labelMap);
|
||||
renderer.renderLabel(&labelFogOfWar);
|
||||
renderer.renderLabel(&labelTileset);
|
||||
renderer.renderLabel(&labelTechTree);
|
||||
renderer.renderLabel(&labelControl);
|
||||
renderer.renderLabel(&labelFaction);
|
||||
renderer.renderLabel(&labelTeam);
|
||||
renderer.renderLabel(&labelMapInfo);
|
||||
|
||||
renderer.renderListBox(&listBoxMap);
|
||||
renderer.renderListBox(&listBoxFogOfWar);
|
||||
renderer.renderListBox(&listBoxTileset);
|
||||
renderer.renderListBox(&listBoxTechTree);
|
||||
|
||||
renderer.renderChatManager(&chatManager);
|
||||
renderer.renderConsole(&console);
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::update()
|
||||
{
|
||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
//update status label
|
||||
if(clientInterface->isConnected())
|
||||
{
|
||||
buttonDisconnect.setText(lang.get("Disconnect"));
|
||||
|
||||
if(clientInterface->getAllowDownloadDataSynch() == false)
|
||||
{
|
||||
string label = lang.get("ConnectedToServer");
|
||||
|
||||
if(!clientInterface->getServerName().empty())
|
||||
{
|
||||
label = label + " " + clientInterface->getServerName();
|
||||
}
|
||||
|
||||
if(clientInterface->getAllowGameDataSynchCheck() == true &&
|
||||
clientInterface->getNetworkGameDataSynchCheckOk() == false)
|
||||
{
|
||||
label = label + " - warning synch mismatch for:";
|
||||
if(clientInterface->getNetworkGameDataSynchCheckOkMap() == false)
|
||||
{
|
||||
label = label + " map";
|
||||
}
|
||||
if(clientInterface->getNetworkGameDataSynchCheckOkTile() == false)
|
||||
{
|
||||
label = label + " tile";
|
||||
}
|
||||
if(clientInterface->getNetworkGameDataSynchCheckOkTech() == false)
|
||||
{
|
||||
label = label + " techtree";
|
||||
}
|
||||
//if(clientInterface->getNetworkGameDataSynchCheckOkFogOfWar() == false)
|
||||
//{
|
||||
// label = label + " FogOfWar == false";
|
||||
//}
|
||||
}
|
||||
else if(clientInterface->getAllowGameDataSynchCheck() == true)
|
||||
{
|
||||
label += " - data synch is ok";
|
||||
}
|
||||
|
||||
labelStatus.setText(label);
|
||||
}
|
||||
else
|
||||
{
|
||||
string label = lang.get("ConnectedToServer");
|
||||
|
||||
if(!clientInterface->getServerName().empty())
|
||||
{
|
||||
label = label + " " + clientInterface->getServerName();
|
||||
}
|
||||
|
||||
if(clientInterface->getAllowGameDataSynchCheck() == true &&
|
||||
clientInterface->getNetworkGameDataSynchCheckOk() == false)
|
||||
{
|
||||
label = label + " - waiting to synch:";
|
||||
if(clientInterface->getNetworkGameDataSynchCheckOkMap() == false)
|
||||
{
|
||||
label = label + " map";
|
||||
}
|
||||
if(clientInterface->getNetworkGameDataSynchCheckOkTile() == false)
|
||||
{
|
||||
label = label + " tile";
|
||||
}
|
||||
if(clientInterface->getNetworkGameDataSynchCheckOkTech() == false)
|
||||
{
|
||||
label = label + " techtree";
|
||||
}
|
||||
//if(clientInterface->getNetworkGameDataSynchCheckOkFogOfWar() == false)
|
||||
//{
|
||||
// label = label + " FogOfWar == false";
|
||||
//}
|
||||
}
|
||||
else if(clientInterface->getAllowGameDataSynchCheck() == true)
|
||||
{
|
||||
label += " - data synch is ok";
|
||||
}
|
||||
|
||||
labelStatus.setText(label);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(clientInterface->getSocket() != NULL)
|
||||
{
|
||||
clientInterface->close();
|
||||
}
|
||||
mainMenu->setState(new MenuStateJoinGame(program, mainMenu));
|
||||
}
|
||||
|
||||
//process network messages
|
||||
if(clientInterface->isConnected())
|
||||
{
|
||||
if(clientInterface->getGameSettingsReceived()){
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
vector<string> maps,tilesets,techtree;
|
||||
const GameSettings *gameSettings=clientInterface->getGameSettings();
|
||||
|
||||
|
||||
// tileset
|
||||
tilesets.push_back(formatString(gameSettings->getTileset()));
|
||||
listBoxTileset.setItems(tilesets);
|
||||
|
||||
// techtree
|
||||
techtree.push_back(formatString(gameSettings->getTech()));
|
||||
listBoxTechTree.setItems(techtree);
|
||||
|
||||
// factions
|
||||
if(currentFactionName!=gameSettings->getTech())
|
||||
{
|
||||
currentFactionName=gameSettings->getTech();
|
||||
loadFactions(gameSettings);
|
||||
}
|
||||
|
||||
// map
|
||||
maps.push_back(formatString(gameSettings->getMap()));
|
||||
listBoxMap.setItems(maps);
|
||||
if(currentMap!=gameSettings->getMap())
|
||||
{// load the setup again
|
||||
currentMap=gameSettings->getMap();
|
||||
}
|
||||
|
||||
|
||||
// FogOfWar
|
||||
if(gameSettings->getFogOfWar()){
|
||||
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
listBoxFogOfWar.setSelectedItemIndex(1);
|
||||
}
|
||||
|
||||
// Control
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
||||
}
|
||||
|
||||
for(int i=0; i<gameSettings->getFactionCount(); ++i){
|
||||
int slot=gameSettings->getStartLocationIndex(i);
|
||||
listBoxControls[slot].setSelectedItemIndex(gameSettings->getFactionControl(i));
|
||||
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i));
|
||||
listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)));
|
||||
}
|
||||
}
|
||||
//update lobby
|
||||
clientInterface->updateLobby();
|
||||
|
||||
//call the chat manager
|
||||
chatManager.updateNetwork();
|
||||
|
||||
//console
|
||||
console.update();
|
||||
|
||||
//intro
|
||||
if(clientInterface->getIntroDone())
|
||||
{
|
||||
labelInfo.setText(lang.get("WaitingHost"));
|
||||
//servers.setString(clientInterface->getServerName(), Ip(labelServerIp.getText()).getString());
|
||||
}
|
||||
|
||||
//launch
|
||||
if(clientInterface->getLaunchGame())
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - A\n",__FILE__,__FUNCTION__);
|
||||
|
||||
//servers.save(serversSavedFile);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - B\n",__FILE__,__FUNCTION__);
|
||||
|
||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - C\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
if(clientInterface->getLaunchGame()) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
vector<string> results;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
|
||||
findAll(techPath + "/" + gameSettings->getTech() + "/factions/*.", results, false, false);
|
||||
if(results.size() > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(results.size() == 0) {
|
||||
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
|
||||
}
|
||||
factionFiles= results;
|
||||
for(int i= 0; i<results.size(); ++i){
|
||||
results[i]= formatString(results[i]);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",gameSettings->getTech().c_str(),results[i].c_str());
|
||||
}
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
listBoxFactions[i].setItems(results);
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ============ PRIVATE ===========================
|
||||
|
||||
bool MenuStateConnectedGame::hasNetworkGameSettings()
|
||||
{
|
||||
bool hasNetworkSlot = false;
|
||||
|
||||
try {
|
||||
for(int i=0; i<mapInfo.players; ++i)
|
||||
{
|
||||
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
|
||||
if(ct != ctClosed)
|
||||
{
|
||||
if(ct == ctNetwork)
|
||||
{
|
||||
hasNetworkSlot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
return hasNetworkSlot;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MenuStateConnectedGame::reloadFactions(){
|
||||
|
||||
vector<string> results;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
|
||||
findAll(techPath + "/" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
if(results.size() > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(results.size() == 0) {
|
||||
throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
|
||||
}
|
||||
factionFiles= results;
|
||||
for(int i= 0; i<results.size(); ++i){
|
||||
results[i]= formatString(results[i]);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",techTreeFiles[listBoxTechTree.getSelectedItemIndex()].c_str(),results[i].c_str());
|
||||
}
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
listBoxFactions[i].setItems(results);
|
||||
listBoxFactions[i].setSelectedItemIndex(i % results.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MenuStateConnectedGame::keyDown(char key)
|
||||
{
|
||||
//send key to the chat manager
|
||||
chatManager.keyDown(key);
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::keyPress(char c)
|
||||
{
|
||||
chatManager.keyPress(c);
|
||||
}
|
||||
|
||||
}}//end namespace
|
|
@ -0,0 +1,80 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code 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 _GLEST_GAME_MENUSTATECONNECTEDGAME_H_
|
||||
#define _GLEST_GAME_MENUSTATECONNECTEDGAME_H_
|
||||
|
||||
#include "main_menu.h"
|
||||
#include "chat_manager.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
// ===============================
|
||||
// class MenuStateConnectedGame
|
||||
// ===============================
|
||||
|
||||
class MenuStateConnectedGame: public MenuState{
|
||||
private:
|
||||
GraphicButton buttonDisconnect;
|
||||
GraphicButton buttonPlayNow;
|
||||
GraphicLabel labelControl;
|
||||
GraphicLabel labelFaction;
|
||||
GraphicLabel labelTeam;
|
||||
GraphicLabel labelMap;
|
||||
GraphicLabel labelFogOfWar;
|
||||
GraphicLabel labelTechTree;
|
||||
GraphicLabel labelTileset;
|
||||
GraphicLabel labelMapInfo;
|
||||
GraphicLabel labelStatus;
|
||||
GraphicLabel labelInfo;
|
||||
|
||||
GraphicListBox listBoxMap;
|
||||
GraphicListBox listBoxFogOfWar;
|
||||
GraphicListBox listBoxTechTree;
|
||||
GraphicListBox listBoxTileset;
|
||||
vector<string> mapFiles;
|
||||
vector<string> techTreeFiles;
|
||||
vector<string> tilesetFiles;
|
||||
vector<string> factionFiles;
|
||||
GraphicLabel labelPlayers[GameConstants::maxPlayers];
|
||||
GraphicListBox listBoxControls[GameConstants::maxPlayers];
|
||||
GraphicListBox listBoxFactions[GameConstants::maxPlayers];
|
||||
GraphicListBox listBoxTeams[GameConstants::maxPlayers];
|
||||
GraphicLabel labelNetStatus[GameConstants::maxPlayers];
|
||||
MapInfo mapInfo;
|
||||
|
||||
bool needToSetChangedGameSettings;
|
||||
time_t lastSetChangedGameSettings;
|
||||
|
||||
Console console;
|
||||
ChatManager chatManager;
|
||||
|
||||
public:
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots= false);
|
||||
|
||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
void update();
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
|
||||
private:
|
||||
|
||||
bool hasNetworkGameSettings();
|
||||
void reloadFactions();
|
||||
void loadFactions(const GameSettings *gameSettings);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
|
@ -520,7 +520,14 @@ void MenuStateCustomGame::update()
|
|||
serverInterface->setGameSettings(&gameSettings);
|
||||
|
||||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
|
||||
if(difftime(time(NULL),lastSetChangedGameSettings) >= 2)
|
||||
{
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
serverInterface->setGameSettings(&gameSettings);
|
||||
serverInterface->broadcastGameSetup(&gameSettings);
|
||||
}
|
||||
|
||||
//call the chat manager
|
||||
|
@ -529,6 +536,10 @@ void MenuStateCustomGame::update()
|
|||
//console
|
||||
console.update();
|
||||
|
||||
if(difftime(time(NULL),lastSetChangedGameSettings) >= 2)
|
||||
{// reset timer here on bottom becasue used for different things
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "menu_state_join_game.h"
|
||||
|
||||
#include "menu_state_connected_game.h"
|
||||
#include "renderer.h"
|
||||
#include "sound_renderer.h"
|
||||
#include "core_data.h"
|
||||
|
@ -37,12 +38,14 @@ using namespace Shared::Util;
|
|||
const int MenuStateJoinGame::newServerIndex= 0;
|
||||
const string MenuStateJoinGame::serverFileName= "servers.ini";
|
||||
|
||||
|
||||
MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool connect, Ip serverIp):
|
||||
MenuState(program, mainMenu, "join-game")
|
||||
{
|
||||
Lang &lang= Lang::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
networkManager.end();
|
||||
|
||||
serversSavedFile = serverFileName;
|
||||
if(getGameReadWritePath() != "") {
|
||||
|
@ -189,7 +192,6 @@ void MenuStateJoinGame::mouseClick(int x, int y, MouseButton mouseButton)
|
|||
}
|
||||
clientInterface->close();
|
||||
}
|
||||
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
}
|
||||
|
||||
|
@ -315,7 +317,6 @@ void MenuStateJoinGame::update()
|
|||
{
|
||||
label += " - data synch is ok";
|
||||
}
|
||||
|
||||
labelStatus.setText(label);
|
||||
}
|
||||
else
|
||||
|
@ -487,7 +488,9 @@ void MenuStateJoinGame::connectToServer()
|
|||
//save server ip
|
||||
config.setString("ServerIp", serverIp.getString());
|
||||
config.save();
|
||||
|
||||
|
||||
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Martiño Figueroa
|
||||
// Copyright (C) 2001-2005 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
|
|
@ -43,6 +43,7 @@ ClientInterface::ClientInterface(){
|
|||
launchGame= false;
|
||||
introDone= false;
|
||||
playerIndex= -1;
|
||||
gameSettingsReceived=false;
|
||||
|
||||
networkGameDataSynchCheckOkMap = false;
|
||||
networkGameDataSynchCheckOkTile = false;
|
||||
|
@ -324,6 +325,35 @@ void ClientInterface::updateLobby()
|
|||
}
|
||||
}
|
||||
break;
|
||||
case nmtBroadCastSetup:
|
||||
{
|
||||
NetworkMessageLaunch networkMessageLaunch;
|
||||
|
||||
if(receiveMessage(&networkMessageLaunch))
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got NetworkMessageLaunch\n",__FILE__,__FUNCTION__);
|
||||
|
||||
networkMessageLaunch.buildGameSettings(&gameSettings);
|
||||
|
||||
//replace server player by network
|
||||
for(int i= 0; i<gameSettings.getFactionCount(); ++i)
|
||||
{
|
||||
//replace by network
|
||||
if(gameSettings.getFactionControl(i)==ctHuman)
|
||||
{
|
||||
gameSettings.setFactionControl(i, ctNetwork);
|
||||
}
|
||||
|
||||
//set the faction index
|
||||
if(gameSettings.getStartLocationIndex(i)==playerIndex)
|
||||
{
|
||||
gameSettings.setThisFactionIndex(i);
|
||||
}
|
||||
}
|
||||
gameSettingsReceived=true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ private:
|
|||
bool introDone;
|
||||
bool launchGame;
|
||||
int playerIndex;
|
||||
bool gameSettingsReceived;
|
||||
|
||||
Ip ip;
|
||||
int port;
|
||||
|
@ -70,6 +71,7 @@ public:
|
|||
string getServerName() const {return serverName;}
|
||||
bool getLaunchGame() const {return launchGame;}
|
||||
bool getIntroDone() const {return introDone;}
|
||||
bool getGameSettingsReceived() const {return gameSettingsReceived;}
|
||||
int getPlayerIndex() const {return playerIndex;}
|
||||
//const GameSettings *getGameSettings() {return &gameSettings;}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ NetworkMessageLaunch::NetworkMessageLaunch(){
|
|||
data.messageType=-1;
|
||||
}
|
||||
|
||||
NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings){
|
||||
data.messageType=nmtLaunch;
|
||||
NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8 messageType){
|
||||
data.messageType=messageType;
|
||||
|
||||
data.description= gameSettings->getDescription();
|
||||
data.map= gameSettings->getMap();
|
||||
|
@ -214,7 +214,6 @@ bool NetworkMessageLaunch::receive(Socket* socket){
|
|||
}
|
||||
|
||||
void NetworkMessageLaunch::send(Socket* socket) const{
|
||||
assert(data.messageType==nmtLaunch);
|
||||
NetworkMessage::send(socket, &data, sizeof(data));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -37,6 +37,8 @@ enum NetworkMessageType{
|
|||
nmtSynchNetworkGameDataStatus,
|
||||
nmtSynchNetworkGameDataFileCRCCheck,
|
||||
nmtSynchNetworkGameDataFileGet,
|
||||
nmtBroadCastSetup,
|
||||
|
||||
|
||||
nmtCount
|
||||
};
|
||||
|
@ -157,7 +159,7 @@ private:
|
|||
|
||||
public:
|
||||
NetworkMessageLaunch();
|
||||
NetworkMessageLaunch(const GameSettings *gameSettings);
|
||||
NetworkMessageLaunch(const GameSettings *gameSettings,int8 messageType);
|
||||
|
||||
void buildGameSettings(GameSettings *gameSettings) const;
|
||||
|
||||
|
|
|
@ -437,7 +437,7 @@ bool ServerInterface::launchGame(const GameSettings* gameSettings){
|
|||
{
|
||||
serverSocket.stopBroadCastThread();
|
||||
|
||||
NetworkMessageLaunch networkMessageLaunch(gameSettings);
|
||||
NetworkMessageLaunch networkMessageLaunch(gameSettings,nmtLaunch);
|
||||
broadcastMessage(&networkMessageLaunch);
|
||||
}
|
||||
|
||||
|
@ -446,6 +446,16 @@ bool ServerInterface::launchGame(const GameSettings* gameSettings){
|
|||
return bOkToStart;
|
||||
}
|
||||
|
||||
void ServerInterface::broadcastGameSetup(const GameSettings* gameSettings){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkMessageLaunch networkMessageLaunch(gameSettings,nmtBroadCastSetup);
|
||||
broadcastMessage(&networkMessageLaunch);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
||||
void ServerInterface::broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot){
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -73,6 +73,7 @@ public:
|
|||
|
||||
bool launchGame(const GameSettings* gameSettings);
|
||||
virtual void setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck = false);
|
||||
void broadcastGameSetup(const GameSettings* gameSettings);
|
||||
|
||||
private:
|
||||
void broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot= -1);
|
||||
|
|
Loading…
Reference in New Issue