mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 12:12:25 +01:00
- Attempt to use libcurl in a thread safe manner
This commit is contained in:
parent
e0b9089eeb
commit
87b4706940
@ -31,6 +31,8 @@ namespace Glest { namespace Game {
|
|||||||
|
|
||||||
// ================== PUBLIC =====================
|
// ================== PUBLIC =====================
|
||||||
|
|
||||||
|
static std::map<std::string, Quad2i> cacheVisibleQuad;
|
||||||
|
|
||||||
const float GameCamera::startingVAng= -60.f;
|
const float GameCamera::startingVAng= -60.f;
|
||||||
const float GameCamera::startingHAng= 0.f;
|
const float GameCamera::startingHAng= 0.f;
|
||||||
const float GameCamera::vTransitionMult= 0.125f;
|
const float GameCamera::vTransitionMult= 0.125f;
|
||||||
@ -40,11 +42,32 @@ const float GameCamera::centerOffsetZ= 8.0f;
|
|||||||
|
|
||||||
// ================= Constructor =================
|
// ================= Constructor =================
|
||||||
|
|
||||||
|
class quadCacheLookup {
|
||||||
|
public:
|
||||||
|
quadCacheLookup(float fov,float hAng,Vec3f pos) {
|
||||||
|
this->fov = fov;
|
||||||
|
this->hAng = hAng;
|
||||||
|
this->pos = pos;
|
||||||
|
}
|
||||||
|
std::string getString() const {
|
||||||
|
std::ostringstream streamOut;
|
||||||
|
streamOut << fov << "_" << hAng << "_" << pos.getString();
|
||||||
|
return streamOut.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
float fov;
|
||||||
|
float hAng;
|
||||||
|
Vec3f pos;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
|
GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
|
||||||
destPos(0.f, defaultHeight, 0.f), destAng(startingVAng, startingHAng) {
|
destPos(0.f, defaultHeight, 0.f), destAng(startingVAng, startingHAng) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
state= sGame;
|
state= sGame;
|
||||||
|
|
||||||
|
cacheVisibleQuad.clear();
|
||||||
|
|
||||||
//config
|
//config
|
||||||
speed= 15.f / GameConstants::cameraFps;
|
speed= 15.f / GameConstants::cameraFps;
|
||||||
clampBounds= !Config::getInstance().getBool("PhotoMode");
|
clampBounds= !Config::getInstance().getBool("PhotoMode");
|
||||||
@ -141,41 +164,19 @@ void GameCamera::update(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Quad2i GameCamera::computeVisibleQuad() const{
|
Quad2i GameCamera::computeVisibleQuad() const {
|
||||||
/*
|
//
|
||||||
class cacheLookup {
|
quadCacheLookup lookup(fov, hAng, pos);
|
||||||
public:
|
|
||||||
cacheLookup(float fov,float hAng,Vec3f pos) {
|
|
||||||
this->fov = fov;
|
|
||||||
this->hAng = hAng;
|
|
||||||
this->pos = pos;
|
|
||||||
}
|
|
||||||
std::string getString() const {
|
|
||||||
std::ostringstream streamOut;
|
|
||||||
streamOut << fov << "_" << hAng << "_" << pos.getString();
|
|
||||||
return streamOut.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
float fov;
|
|
||||||
float hAng;
|
|
||||||
Vec3f pos;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
cacheLookup lookup(fov, hAng,pos);
|
|
||||||
string lookupKey = lookup.getString();
|
string lookupKey = lookup.getString();
|
||||||
|
std::map<std::string, Quad2i>::const_iterator iterFind = cacheVisibleQuad.find(lookupKey);
|
||||||
static std::map<string, Quad2i> cacheQuad;
|
if(iterFind != cacheVisibleQuad.end()) {
|
||||||
if(cacheQuad.find(lookupKey) != cacheQuad.end()) {
|
return iterFind->second;
|
||||||
return cacheQuad[lookupKey];
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
*/
|
|
||||||
|
|
||||||
float nearDist = 20.f;
|
float nearDist = 20.f;
|
||||||
float dist = pos.y > 20.f ? pos.y * 1.2f : 20.f;
|
float dist = pos.y > 20.f ? pos.y * 1.2f : 20.f;
|
||||||
float farDist = 90.f * (pos.y > 20.f ? pos.y / 15.f : 1.f);
|
float farDist = 90.f * (pos.y > 20.f ? pos.y / 15.f : 1.f);
|
||||||
//float fov = Config::getInstance().getFloat("CameraFov","45");
|
|
||||||
|
|
||||||
#ifdef USE_STREFLOP
|
#ifdef USE_STREFLOP
|
||||||
Vec2f v(streflop::sinf(degToRad(180 - hAng)), streflop::cosf(degToRad(180 - hAng)));
|
Vec2f v(streflop::sinf(degToRad(180 - hAng)), streflop::cosf(degToRad(180 - hAng)));
|
||||||
@ -207,10 +208,10 @@ Quad2i GameCamera::computeVisibleQuad() const{
|
|||||||
return Quad2i(p2, p4, p1, p3);
|
return Quad2i(p2, p4, p1, p3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cacheQuad[lookupKey] = Quad2i(p4, p3, p2, p1);
|
//cacheVisibleQuad[lookupKey] = Quad2i(p4, p3, p2, p1);
|
||||||
// return cacheQuad[lookupKey];
|
cacheVisibleQuad.insert(std::make_pair(lookupKey,Quad2i(p4, p3, p2, p1)));
|
||||||
|
return cacheVisibleQuad[lookupKey];
|
||||||
return Quad2i(p4, p3, p2, p1);
|
// return Quad2i(p4, p3, p2, p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameCamera::switchState(){
|
void GameCamera::switchState(){
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
#include "math_util.h"
|
#include "math_util.h"
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Shared { namespace Xml {
|
namespace Shared { namespace Xml {
|
||||||
class XmlNode;
|
class XmlNode;
|
||||||
|
@ -530,7 +530,7 @@ void Renderer::loadGameCameraMatrix(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::loadCameraMatrix(const Camera *camera){
|
void Renderer::loadCameraMatrix(const Camera *camera){
|
||||||
Vec3f position= camera->getPosition();
|
const Vec3f &position= camera->getConstPosition();
|
||||||
Quaternion orientation= camera->getOrientation().conjugate();
|
Quaternion orientation= camera->getOrientation().conjugate();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@ -2072,7 +2072,7 @@ void Renderer::renderMenuBackground(const MenuBackground *menuBackground){
|
|||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
Vec3f cameraPosition= menuBackground->getCamera()->getPosition();
|
const Vec3f &cameraPosition= menuBackground->getCamera()->getConstPosition();
|
||||||
|
|
||||||
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
|
glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#include "menu_state_custom_game.h"
|
#include "menu_state_custom_game.h"
|
||||||
|
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
@ -322,10 +321,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
MenuStateCustomGame::~MenuStateCustomGame() {
|
MenuStateCustomGame::~MenuStateCustomGame() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
@ -337,11 +334,9 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
|||||||
void MenuStateCustomGame::returnToParentMenu(){
|
void MenuStateCustomGame::returnToParentMenu(){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
bool returnToMasterServerMenu = parentMenuIsMs;
|
bool returnToMasterServerMenu = parentMenuIsMs;
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
@ -440,9 +435,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
}
|
}
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
|
|
||||||
@ -623,8 +617,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
|
|
||||||
if (mainMessageBox.getEnabled()) {
|
if (mainMessageBox.getEnabled()) {
|
||||||
mainMessageBox.mouseMove(x, y);
|
mainMessageBox.mouseMove(x, y);
|
||||||
}
|
}
|
||||||
@ -649,12 +641,9 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::render(){
|
void MenuStateCustomGame::render(){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
|
|
||||||
if(mainMessageBox.getEnabled()){
|
if(mainMessageBox.getEnabled()){
|
||||||
renderer.renderMessageBox(&mainMessageBox);
|
renderer.renderMessageBox(&mainMessageBox);
|
||||||
}
|
}
|
||||||
@ -711,59 +700,67 @@ void MenuStateCustomGame::render(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::update()
|
void MenuStateCustomGame::update() {
|
||||||
{
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(serverInitError == true) {
|
if(serverInitError == true) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(showGeneralError) {
|
if(showGeneralError) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
||||||
showGeneralError=false;
|
showGeneralError=false;
|
||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
showMessageBox( generalErrorToShow, "Error", false);
|
showMessageBox( generalErrorToShow, "Error", false);
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
Lang& lang= Lang::getInstance();
|
Lang& lang= Lang::getInstance();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
bool haveAtLeastOneNetworkClientConnected = false;
|
bool haveAtLeastOneNetworkClientConnected = false;
|
||||||
bool hasOneNetworkSlotOpen = false;
|
bool hasOneNetworkSlotOpen = false;
|
||||||
int currentConnectionCount=0;
|
int currentConnectionCount=0;
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
bool masterServerErr = showMasterserverError;
|
bool masterServerErr = showMasterserverError;
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(masterServerErr)
|
if(masterServerErr)
|
||||||
{
|
{
|
||||||
safeMutex.Lock();
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(EndsWith(masterServererErrorToShow, "wrong router setup") == true)
|
if(EndsWith(masterServererErrorToShow, "wrong router setup") == true)
|
||||||
{
|
{
|
||||||
masterServererErrorToShow=lang.get("wrong router setup");
|
masterServererErrorToShow=lang.get("wrong router setup");
|
||||||
}
|
}
|
||||||
showMasterserverError=false;
|
showMasterserverError=false;
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
|
||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false);
|
showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
}
|
}
|
||||||
else if(showGeneralError) {
|
else if(showGeneralError) {
|
||||||
safeMutex.Lock();
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
showGeneralError=false;
|
showGeneralError=false;
|
||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
showMessageBox( generalErrorToShow, "Error", false);
|
showMessageBox( generalErrorToShow, "Error", false);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
// handle setting changes from clients
|
// handle setting changes from clients
|
||||||
SwitchSetupRequest** switchSetupRequests=serverInterface->getSwitchSetupRequests();
|
SwitchSetupRequest** switchSetupRequests=serverInterface->getSwitchSetupRequests();
|
||||||
safeMutex.Lock();
|
|
||||||
for(int i= 0; i<mapInfo.players; ++i)
|
for(int i= 0; i<mapInfo.players; ++i)
|
||||||
{
|
{
|
||||||
if(switchSetupRequests[i]!=NULL)
|
if(switchSetupRequests[i]!=NULL)
|
||||||
@ -813,11 +810,9 @@ void MenuStateCustomGame::update()
|
|||||||
switchSetupRequests[i]=NULL;
|
switchSetupRequests[i]=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] mapInfo.players = %d\n",__FILE__,__FUNCTION__,__LINE__,mapInfo.players);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] mapInfo.players = %d\n",__FILE__,__FUNCTION__,__LINE__,mapInfo.players);
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
for(int i= 0; i<mapInfo.players; ++i)
|
for(int i= 0; i<mapInfo.players; ++i)
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@ -919,16 +914,13 @@ void MenuStateCustomGame::update()
|
|||||||
labelNetStatus[i].setText("");
|
labelNetStatus[i].setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
bool checkDataSynch = (serverInterface->getAllowGameDataSynchCheck() == true &&
|
bool checkDataSynch = (serverInterface->getAllowGameDataSynchCheck() == true &&
|
||||||
//haveAtLeastOneNetworkClientConnected == true &&
|
//haveAtLeastOneNetworkClientConnected == true &&
|
||||||
needToSetChangedGameSettings == true &&
|
needToSetChangedGameSettings == true &&
|
||||||
difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
// Send the game settings to each client if we have at least one networked client
|
// Send the game settings to each client if we have at least one networked client
|
||||||
if(checkDataSynch == true)
|
if(checkDataSynch == true)
|
||||||
@ -936,61 +928,44 @@ void MenuStateCustomGame::update()
|
|||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
serverInterface->setGameSettings(&gameSettings);
|
serverInterface->setGameSettings(&gameSettings);
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(hasOneNetworkSlotOpen)
|
if(hasOneNetworkSlotOpen)
|
||||||
{
|
{
|
||||||
safeMutex.Lock();
|
|
||||||
//listBoxPublishServer.setSelectedItemIndex(0);
|
//listBoxPublishServer.setSelectedItemIndex(0);
|
||||||
listBoxPublishServer.setEditable(true);
|
listBoxPublishServer.setEditable(true);
|
||||||
listBoxEnableServerControlledAI.setEditable(true);
|
listBoxEnableServerControlledAI.setEditable(true);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
safeMutex.Lock();
|
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
listBoxPublishServer.setEditable(false);
|
listBoxPublishServer.setEditable(false);
|
||||||
listBoxEnableServerControlledAI.setEditable(false);
|
listBoxEnableServerControlledAI.setEditable(false);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
bool republishToMaster = (difftime(time(NULL),lastMasterserverPublishing) >= 5);
|
bool republishToMaster = (difftime(time(NULL),lastMasterserverPublishing) >= 5);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(republishToMaster == true) {
|
if(republishToMaster == true) {
|
||||||
safeMutex.Lock();
|
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
lastMasterserverPublishing = time(NULL);
|
lastMasterserverPublishing = time(NULL);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
bool callPublishNow = (listBoxPublishServer.getEditable() &&
|
bool callPublishNow = (listBoxPublishServer.getEditable() &&
|
||||||
listBoxPublishServer.getSelectedItemIndex() == 0 &&
|
listBoxPublishServer.getSelectedItemIndex() == 0 &&
|
||||||
needToRepublishToMasterserver == true);
|
needToRepublishToMasterserver == true);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(callPublishNow == true) {
|
if(callPublishNow == true) {
|
||||||
// give it to me baby, aha aha ...
|
// give it to me baby, aha aha ...
|
||||||
publishToMasterserver();
|
publishToMasterserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
bool broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
bool broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(broadCastSettings == true) {
|
if(broadCastSettings == true) {
|
||||||
safeMutex.Lock();
|
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//call the chat manager
|
//call the chat manager
|
||||||
@ -999,25 +974,19 @@ void MenuStateCustomGame::update()
|
|||||||
//console
|
//console
|
||||||
console.update();
|
console.update();
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(broadCastSettings == true)
|
if(broadCastSettings == true)
|
||||||
{// reset timer here on bottom becasue used for different things
|
{// reset timer here on bottom becasue used for different things
|
||||||
safeMutex.Lock();
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
lastSetChangedGameSettings = time(NULL);
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
safeMutex.Lock();
|
|
||||||
if(currentConnectionCount > soundConnectionCount){
|
if(currentConnectionCount > soundConnectionCount){
|
||||||
soundConnectionCount = currentConnectionCount;
|
soundConnectionCount = currentConnectionCount;
|
||||||
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
||||||
}
|
}
|
||||||
soundConnectionCount = currentConnectionCount;
|
soundConnectionCount = currentConnectionCount;
|
||||||
safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
@ -1034,15 +1003,19 @@ void MenuStateCustomGame::update()
|
|||||||
|
|
||||||
void MenuStateCustomGame::publishToMasterserver()
|
void MenuStateCustomGame::publishToMasterserver()
|
||||||
{
|
{
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
int slotCountUsed=0;
|
int slotCountUsed=0;
|
||||||
int slotCountHumans=0;
|
int slotCountHumans=0;
|
||||||
int slotCountConnectedPlayers=0;
|
int slotCountConnectedPlayers=0;
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
string serverinfo="";
|
//string serverinfo="";
|
||||||
|
publishToServerInfo.clear();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
for(int i= 0; i < mapInfo.players; ++i) {
|
for(int i= 0; i < mapInfo.players; ++i) {
|
||||||
if(listBoxControls[i].getSelectedItemIndex() != ctClosed) {
|
if(listBoxControls[i].getSelectedItemIndex() != ctClosed) {
|
||||||
slotCountUsed++;
|
slotCountUsed++;
|
||||||
@ -1063,74 +1036,71 @@ void MenuStateCustomGame::publishToMasterserver()
|
|||||||
slotCountConnectedPlayers++;
|
slotCountConnectedPlayers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//?status=waiting&system=linux&info=titus
|
//?status=waiting&system=linux&info=titus
|
||||||
serverinfo += "glestVersion=" + SystemFlags::escapeURL(glestVersionString) + "&";
|
publishToServerInfo["glestVersion"] = glestVersionString;
|
||||||
serverinfo += "platform=" + SystemFlags::escapeURL(getPlatformNameString()) + "&";
|
publishToServerInfo["platform"] = getPlatformNameString();
|
||||||
serverinfo += "binaryCompileDate=" + SystemFlags::escapeURL(getCompileDateTime()) + "&";
|
publishToServerInfo["binaryCompileDate"] = getCompileDateTime();
|
||||||
|
|
||||||
//game info:
|
//game info:
|
||||||
serverinfo += "serverTitle=" + SystemFlags::escapeURL(Config::getInstance().getString("NetPlayerName") + "'s game") + "&";
|
publishToServerInfo["serverTitle"] = Config::getInstance().getString("NetPlayerName") + "'s game";
|
||||||
//ip is automatically set
|
//ip is automatically set
|
||||||
|
|
||||||
//game setup info:
|
//game setup info:
|
||||||
serverinfo += "tech=" + SystemFlags::escapeURL(listBoxTechTree.getSelectedItem()) + "&";
|
publishToServerInfo["tech"] = listBoxTechTree.getSelectedItem();
|
||||||
serverinfo += "map=" + SystemFlags::escapeURL(listBoxMap.getSelectedItem()) + "&";
|
publishToServerInfo["map"] = listBoxMap.getSelectedItem();
|
||||||
serverinfo += "tileset=" + SystemFlags::escapeURL(listBoxTileset.getSelectedItem()) + "&";
|
publishToServerInfo["tileset"] = listBoxTileset.getSelectedItem();
|
||||||
serverinfo += "activeSlots=" + intToStr(slotCountUsed) + "&";
|
publishToServerInfo["activeSlots"] = intToStr(slotCountUsed);
|
||||||
serverinfo += "networkSlots=" + intToStr(slotCountHumans) + "&";
|
publishToServerInfo["networkSlots"] = intToStr(slotCountHumans);
|
||||||
serverinfo += "connectedClients=" + intToStr(slotCountConnectedPlayers);
|
publishToServerInfo["connectedClients"] = intToStr(slotCountConnectedPlayers);
|
||||||
|
|
||||||
publishToServerInfo = serverinfo;
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::simpleTask() {
|
void MenuStateCustomGame::simpleTask() {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo != "");
|
bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0);
|
||||||
if(publishToMasterserverThread == NULL || publishToMasterserverThread->getQuitStatus() == true || publishToMasterserverThread->getRunningStatus() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
string newPublishToServerInfo = publishToServerInfo;
|
|
||||||
publishToServerInfo = "";
|
|
||||||
//safeMutex.ReleaseLock(true);
|
|
||||||
|
|
||||||
if(republish == true) {
|
if(republish == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?" + newPublishToServerInfo;
|
//string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?" + newPublishToServerInfo;
|
||||||
|
string request = Config::getInstance().getString("Masterserver") + "addServerInfo.php?";
|
||||||
|
|
||||||
|
CURL *handle = SystemFlags::initHTTP();
|
||||||
|
for(std::map<string,string>::const_iterator iterMap = publishToServerInfo.begin();
|
||||||
|
iterMap != publishToServerInfo.end(); iterMap++) {
|
||||||
|
|
||||||
|
request += iterMap->first;
|
||||||
|
request += "=";
|
||||||
|
request += SystemFlags::escapeURL(iterMap->second,handle);
|
||||||
|
request += "&";
|
||||||
|
}
|
||||||
|
publishToServerInfo.clear();
|
||||||
|
|
||||||
//printf("the request is:\n%s\n",request.c_str());
|
//printf("the request is:\n%s\n",request.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the request is:\n%s\n",__FILE__,__FUNCTION__,__LINE__,request.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the request is:\n%s\n",__FILE__,__FUNCTION__,__LINE__,request.c_str());
|
||||||
|
|
||||||
if(publishToMasterserverThread == NULL || publishToMasterserverThread->getQuitStatus() == true || publishToMasterserverThread->getRunningStatus() == false) {
|
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
||||||
return;
|
SystemFlags::cleanupHTTP(&handle);
|
||||||
}
|
|
||||||
|
|
||||||
std::string serverInfo = SystemFlags::getHTTP(request);
|
|
||||||
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
||||||
|
|
||||||
// uncomment to enable router setup check of this server
|
// uncomment to enable router setup check of this server
|
||||||
//if(serverInfo!="OK")
|
|
||||||
if(EndsWith(serverInfo, "OK") == false) {
|
if(EndsWith(serverInfo, "OK") == false) {
|
||||||
//safeMutex.Lock();
|
|
||||||
showMasterserverError=true;
|
showMasterserverError=true;
|
||||||
masterServererErrorToShow=serverInfo;
|
masterServererErrorToShow=serverInfo;
|
||||||
//safeMutex.ReleaseLock(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//safeMutex.Lock();
|
|
||||||
bool broadCastSettings = needToBroadcastServerSettings;
|
bool broadCastSettings = needToBroadcastServerSettings;
|
||||||
if(publishToMasterserverThread == NULL || publishToMasterserverThread->getQuitStatus() == true || publishToMasterserverThread->getRunningStatus() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
needToBroadcastServerSettings=false;
|
needToBroadcastServerSettings=false;
|
||||||
//safeMutex.ReleaseLock(true);
|
//safeMutex.ReleaseLock(true);
|
||||||
|
|
||||||
@ -1144,17 +1114,9 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
if(serverInterface->hasClientConnection() == true) {
|
if(serverInterface->hasClientConnection() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(publishToMasterserverThread == NULL || publishToMasterserverThread->getQuitStatus() == true || publishToMasterserverThread->getRunningStatus() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
|
|
||||||
if(publishToMasterserverThread == NULL || publishToMasterserverThread->getQuitStatus() == true || publishToMasterserverThread->getRunningStatus() == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
serverInterface->setGameSettings(&gameSettings);
|
serverInterface->setGameSettings(&gameSettings);
|
||||||
@ -1168,8 +1130,6 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
|
|
||||||
int factionCount= 0;
|
int factionCount= 0;
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
||||||
@ -1228,8 +1188,6 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTech() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTech().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTech() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTech().c_str());
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getMap() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getMap().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getMap() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getMap().c_str());
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1524,7 +1482,6 @@ void MenuStateCustomGame::updateControlers(){
|
|||||||
|
|
||||||
void MenuStateCustomGame::closeUnusedSlots(){
|
void MenuStateCustomGame::closeUnusedSlots(){
|
||||||
try {
|
try {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
for(int i= 0; i<mapInfo.players; ++i){
|
for(int i= 0; i<mapInfo.players; ++i){
|
||||||
if(listBoxControls[i].getSelectedItemIndex()==ctNetwork){
|
if(listBoxControls[i].getSelectedItemIndex()==ctNetwork){
|
||||||
|
@ -71,7 +71,7 @@ private:
|
|||||||
time_t lastMasterserverPublishing;
|
time_t lastMasterserverPublishing;
|
||||||
bool needToRepublishToMasterserver;
|
bool needToRepublishToMasterserver;
|
||||||
bool needToBroadcastServerSettings;
|
bool needToBroadcastServerSettings;
|
||||||
string publishToServerInfo;
|
std::map<string,string> publishToServerInfo;
|
||||||
SimpleTaskThread *publishToMasterserverThread;
|
SimpleTaskThread *publishToMasterserverThread;
|
||||||
Mutex masterServerThreadAccessor;
|
Mutex masterServerThreadAccessor;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ MenuStateMasterserver::~MenuStateMasterserver() {
|
|||||||
|
|
||||||
clearServerLines();
|
clearServerLines();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] END\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::clearServerLines(){
|
void MenuStateMasterserver::clearServerLines(){
|
||||||
@ -265,10 +265,10 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
needUpdateFromServer = false;
|
needUpdateFromServer = false;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
//BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||||
delete updateFromMasterserverThread;
|
delete updateFromMasterserverThread;
|
||||||
updateFromMasterserverThread = NULL;
|
updateFromMasterserverThread = NULL;
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ void ClientInterface::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int lastSendElapsed = difftime(time(NULL),lastNetworkCommandListSendTime);
|
int lastSendElapsed = difftime(time(NULL),lastNetworkCommandListSendTime);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] lastSendElapsed = %d\n",__FILE__,__FUNCTION__,__LINE__,lastSendElapsed);
|
if(lastNetworkCommandListSendTime > 0) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] lastSendElapsed = %d\n",__FILE__,__FUNCTION__,__LINE__,lastSendElapsed);
|
||||||
|
|
||||||
if(networkMessageCommandList.getCommandCount() > 0 ||
|
if(networkMessageCommandList.getCommandCount() > 0 ||
|
||||||
(lastNetworkCommandListSendTime > 0 && lastSendElapsed >= ClientInterface::maxNetworkCommandListSendTimeWait)) {
|
(lastNetworkCommandListSendTime > 0 && lastSendElapsed >= ClientInterface::maxNetworkCommandListSendTimeWait)) {
|
||||||
|
@ -180,9 +180,14 @@ ConnectionSlot::~ConnectionSlot()
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
||||||
|
|
||||||
BaseThread::shutdownAndWait(slotThreadWorker);
|
BaseThread::shutdownAndWait(slotThreadWorker);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
delete slotThreadWorker;
|
delete slotThreadWorker;
|
||||||
slotThreadWorker = NULL;
|
slotThreadWorker = NULL;
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
close();
|
close();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||||
|
51
source/shared_lib/include/graphics/camera.h
Normal file
51
source/shared_lib/include/graphics/camera.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Martio 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 _SHARED_GRAPHICS_CAMERA_H_
|
||||||
|
#define _SHARED_GRAPHICS_CAMERA_H_
|
||||||
|
|
||||||
|
#include "vec.h"
|
||||||
|
#include "quaternion.h"
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class Camera
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
class Camera{
|
||||||
|
private:
|
||||||
|
Quaternion orientation;
|
||||||
|
Vec3f position;
|
||||||
|
public:
|
||||||
|
Camera();
|
||||||
|
|
||||||
|
Vec3f getPosition() const {return position;}
|
||||||
|
Quaternion getOrientation() const {return orientation;}
|
||||||
|
|
||||||
|
const Vec3f & getConstPosition() const {return position;}
|
||||||
|
const Quaternion & getConstOrientation() const {return orientation;}
|
||||||
|
|
||||||
|
void setPosition(const Vec3f &position) {this->position= position;}
|
||||||
|
void setOrientation(const Quaternion &orientation) {this->orientation= orientation;}
|
||||||
|
|
||||||
|
void moveLocalX(float amount);
|
||||||
|
void moveLocalY(float amount);
|
||||||
|
void moveLocalZ(float amount);
|
||||||
|
|
||||||
|
void addYaw(float amount);
|
||||||
|
void addPitch(float amount);
|
||||||
|
void addRoll(float amount);
|
||||||
|
};
|
||||||
|
|
||||||
|
}}//end namespace
|
||||||
|
|
||||||
|
#endif
|
@ -116,8 +116,11 @@ public:
|
|||||||
static void init();
|
static void init();
|
||||||
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
|
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
|
||||||
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
||||||
static std::string getHTTP(std::string URL);
|
static std::string getHTTP(std::string URL,CURL *handle=NULL);
|
||||||
static std::string escapeURL(std::string URL);
|
static std::string escapeURL(std::string URL, CURL *handle=NULL);
|
||||||
|
|
||||||
|
static CURL *initHTTP();
|
||||||
|
static void cleanupHTTP(CURL **handle);
|
||||||
|
|
||||||
// Let the macro call into this when require.. NEVER call it automatically.
|
// Let the macro call into this when require.. NEVER call it automatically.
|
||||||
static void handleDebug(DebugType type, const char *fmt, ...);
|
static void handleDebug(DebugType type, const char *fmt, ...);
|
||||||
|
@ -33,7 +33,7 @@ BaseThread::BaseThread() : Thread() {
|
|||||||
BaseThread::~BaseThread() {
|
BaseThread::~BaseThread() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
shutdownAndWait();
|
shutdownAndWait();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::signalQuit() {
|
void BaseThread::signalQuit() {
|
||||||
@ -98,20 +98,20 @@ void BaseThread::shutdownAndWait(BaseThread *pThread) {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
|
|
||||||
pThread->signalQuit();
|
pThread->signalQuit();
|
||||||
sleep(0);
|
//sleep(0);
|
||||||
|
|
||||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 7; ) {
|
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) {
|
||||||
if(pThread->getRunningStatus() == false) {
|
if(pThread->getRunningStatus() == false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(0);
|
sleep(1);
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
//sleep(0);
|
//sleep(0);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
//sleep(0);
|
//sleep(0);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseThread::shutdownAndWait() {
|
void BaseThread::shutdownAndWait() {
|
||||||
|
@ -145,7 +145,7 @@ void SimpleTaskThread::execute() {
|
|||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
setRunningStatus(false);
|
setRunningStatus(false);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] END\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleTaskThread::setTaskSignalled(bool value) {
|
void SimpleTaskThread::setTaskSignalled(bool value) {
|
||||||
|
@ -708,6 +708,7 @@ float Socket::getThreadedPingMS(std::string host) {
|
|||||||
if(pingThread == NULL) {
|
if(pingThread == NULL) {
|
||||||
lastThreadedPing = 0;
|
lastThreadedPing = 0;
|
||||||
pingThread = new SimpleTaskThread(this,0,50);
|
pingThread = new SimpleTaskThread(this,0,50);
|
||||||
|
pingThread->setUniqueID(__FILE__ + "_" + __FUNCTION);
|
||||||
pingThread->start();
|
pingThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1216,6 +1217,7 @@ void ClientSocket::startBroadCastClientThread(DiscoveredServersInterface *cb) {
|
|||||||
ClientSocket::stopBroadCastClientThread();
|
ClientSocket::stopBroadCastClientThread();
|
||||||
|
|
||||||
broadCastClientThread = new BroadCastClientSocketThread(cb);
|
broadCastClientThread = new BroadCastClientSocketThread(cb);
|
||||||
|
broadCastClientThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
|
||||||
broadCastClientThread->start();
|
broadCastClientThread->start();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@ -1495,6 +1497,7 @@ void ServerSocket::startBroadCastThread() {
|
|||||||
stopBroadCastThread();
|
stopBroadCastThread();
|
||||||
|
|
||||||
broadCastThread = new BroadCastSocketThread();
|
broadCastThread = new BroadCastSocketThread();
|
||||||
|
broadCastThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
|
||||||
broadCastThread->start();
|
broadCastThread->start();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -69,11 +69,13 @@ size_t SystemFlags::httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb
|
|||||||
return realsize;
|
return realsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemFlags::escapeURL(std::string URL)
|
std::string SystemFlags::escapeURL(std::string URL, CURL *handle) {
|
||||||
{
|
|
||||||
string result = URL;
|
string result = URL;
|
||||||
|
|
||||||
char *escaped=curl_easy_escape(SystemFlags::curl_handle,URL.c_str(),0);
|
if(handle == NULL) {
|
||||||
|
handle = SystemFlags::curl_handle;
|
||||||
|
}
|
||||||
|
char *escaped=curl_easy_escape(handle,URL.c_str(),0);
|
||||||
if(escaped != NULL) {
|
if(escaped != NULL) {
|
||||||
result = escaped;
|
result = escaped;
|
||||||
curl_free(escaped);
|
curl_free(escaped);
|
||||||
@ -81,33 +83,56 @@ std::string SystemFlags::escapeURL(std::string URL)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemFlags::getHTTP(std::string URL) {
|
std::string SystemFlags::getHTTP(std::string URL,CURL *handle) {
|
||||||
curl_easy_setopt(SystemFlags::curl_handle, CURLOPT_URL, URL.c_str());
|
if(handle == NULL) {
|
||||||
|
handle = SystemFlags::curl_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
curl_easy_setopt(handle, CURLOPT_URL, URL.c_str());
|
||||||
|
|
||||||
/* send all data to this function */
|
/* send all data to this function */
|
||||||
curl_easy_setopt(SystemFlags::curl_handle, CURLOPT_WRITEFUNCTION, SystemFlags::httpWriteMemoryCallback);
|
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, SystemFlags::httpWriteMemoryCallback);
|
||||||
|
|
||||||
struct SystemFlags::httpMemoryStruct chunk;
|
struct SystemFlags::httpMemoryStruct chunk;
|
||||||
chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
|
chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
|
||||||
chunk.size = 0; /* no data at this point */
|
chunk.size = 0; /* no data at this point */
|
||||||
|
|
||||||
/* we pass our 'chunk' struct to the callback function */
|
/* we pass our 'chunk' struct to the callback function */
|
||||||
curl_easy_setopt(SystemFlags::curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
|
curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *)&chunk);
|
||||||
|
|
||||||
/* some servers don't like requests that are made without a user-agent
|
/* some servers don't like requests that are made without a user-agent
|
||||||
field, so we provide one */
|
field, so we provide one */
|
||||||
curl_easy_setopt(SystemFlags::curl_handle, CURLOPT_USERAGENT, "mega-glest-agent/1.0");
|
curl_easy_setopt(handle, CURLOPT_USERAGENT, "mega-glest-agent/1.0");
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] handle = %p\n",__FILE__,__FUNCTION__,__LINE__,handle);
|
||||||
|
|
||||||
|
//curl_easy_setopt(handle, CURLOPT_VERBOSE, 1);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
/* get contents from the URL */
|
/* get contents from the URL */
|
||||||
curl_easy_perform(SystemFlags::curl_handle);
|
curl_easy_perform(handle);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
std::string serverResponse = (chunk.memory != NULL ? chunk.memory : "");
|
std::string serverResponse = (chunk.memory != NULL ? chunk.memory : "");
|
||||||
if(chunk.memory) {
|
if(chunk.memory) {
|
||||||
free(chunk.memory);
|
free(chunk.memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] serverResponse [%s]\n",__FILE__,__FUNCTION__,__LINE__,serverResponse.c_str());
|
||||||
|
|
||||||
return serverResponse;
|
return serverResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CURL *SystemFlags::initHTTP() {
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
CURL *handle = curl_easy_init();
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
void SystemFlags::init() {
|
void SystemFlags::init() {
|
||||||
if(SystemFlags::debugLogFileList.size() == 0) {
|
if(SystemFlags::debugLogFileList.size() == 0) {
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
||||||
@ -117,9 +142,15 @@ void SystemFlags::init() {
|
|||||||
SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(curl_handle == NULL) {
|
if(curl_handle == NULL) {
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
|
||||||
curl_handle = curl_easy_init();
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
curl_handle = SystemFlags::initHTTP();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] curl_handle = %p\n",__FILE__,__FUNCTION__,__LINE__,curl_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,13 +172,21 @@ inline bool acquire_file_lock(int hnd)
|
|||||||
SystemFlags::SystemFlags() {
|
SystemFlags::SystemFlags() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemFlags::cleanupHTTP(CURL **handle) {
|
||||||
|
if(handle != NULL && *handle != NULL) {
|
||||||
|
curl_easy_cleanup(*handle);
|
||||||
|
*handle = NULL;
|
||||||
|
curl_global_cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::~SystemFlags() {
|
SystemFlags::~SystemFlags() {
|
||||||
SystemFlags::Close();
|
SystemFlags::Close();
|
||||||
|
|
||||||
if(curl_handle != NULL) {
|
if(curl_handle != NULL) {
|
||||||
curl_easy_cleanup(curl_handle);
|
SystemFlags::cleanupHTTP(&curl_handle);
|
||||||
curl_handle = NULL;
|
curl_handle = NULL;
|
||||||
curl_global_cleanup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user