mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 05:43:59 +02:00
- make pathfinder caching an ini setting tso its easy to test (disabled by default)
- some code cleanup related to threads and sockets
This commit is contained in:
@@ -356,7 +356,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
|
||||
UnitPathInterface *path= unit->getPath();
|
||||
// Check the previous path find cache for the unit to see if its good to
|
||||
// use
|
||||
const bool tryLastPathCache = false;
|
||||
const bool tryLastPathCache = Config::getInstance().getBool("EnablePathfinderCache","false");
|
||||
if(tryLastPathCache == true && path != NULL) {
|
||||
UnitPathBasic *basicPathFinder = dynamic_cast<UnitPathBasic *>(path);
|
||||
if(basicPathFinder != NULL && basicPathFinder->getLastPathCacheQueueCount() > 0) {
|
||||
|
@@ -126,7 +126,7 @@ const float Renderer::magicCircleRadius= 1.f;
|
||||
|
||||
//perspective values
|
||||
const float Renderer::perspFov= 60.f;
|
||||
const float Renderer::perspNearPlane= 2.f;
|
||||
const float Renderer::perspNearPlane= 1.f;
|
||||
//const float Renderer::perspFarPlane= 50.f;
|
||||
const float Renderer::perspFarPlane= 1000.f;
|
||||
|
||||
@@ -2591,8 +2591,8 @@ void Renderer::renderSelectionEffects() {
|
||||
(showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) {
|
||||
|
||||
const UnitPathInterface *path= unit->getPath();
|
||||
if(path != NULL) {
|
||||
vector<Vec2i> pathList = path->getQueue();
|
||||
if(path != NULL && dynamic_cast<const UnitPathBasic *>(path)) {
|
||||
vector<Vec2i> pathList = dynamic_cast<const UnitPathBasic *>(path)->getLastPathCacheQueue();
|
||||
|
||||
Vec2i lastPosValue;
|
||||
for(int i = 0; i < pathList.size(); ++i) {
|
||||
|
@@ -324,7 +324,7 @@ void ServerInterface::slotUpdateTask(ConnectionSlotEvent *event) {
|
||||
}
|
||||
|
||||
void ServerInterface::updateSlot(ConnectionSlotEvent *event) {
|
||||
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__);
|
||||
if(event != NULL) {
|
||||
bool &socketTriggered = event->socketTriggered;
|
||||
bool checkForNewClients = true;
|
||||
@@ -509,7 +509,7 @@ void ServerInterface::updateSocketTriggeredList(std::map<PLATFORM_SOCKET,bool> &
|
||||
MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i));
|
||||
ConnectionSlot* connectionSlot= slots[i];
|
||||
if(connectionSlot != NULL && connectionSlot->getSocket() != NULL &&
|
||||
slots[i]->getSocket()->isSocketValid() == true) {
|
||||
connectionSlot->getSocket()->isSocketValid() == true) {
|
||||
socketTriggeredList[connectionSlot->getSocket()->getSocketId()] = false;
|
||||
}
|
||||
}
|
||||
@@ -1188,6 +1188,7 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) {
|
||||
ftpServer = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||
MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i));
|
||||
@@ -1197,6 +1198,7 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) {
|
||||
connectionSlot->getSocket()->setBlock(true);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@@ -844,6 +844,7 @@ void Socket::disconnectSocket() {
|
||||
::closesocket(sock);
|
||||
sock = -1;
|
||||
#endif
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END closing socket = %d...\n",__FILE__,__FUNCTION__,sock);
|
||||
@@ -893,7 +894,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||
{
|
||||
bResult = true;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] select detected data imaxsocket = %d...\n",__FILE__,__FUNCTION__,imaxsocket);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] select detected data imaxsocket = %d...\n",__FILE__,__FUNCTION__,imaxsocket);
|
||||
|
||||
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
||||
itermap != socketTriggeredList.end(); itermap++)
|
||||
@@ -901,7 +902,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||
PLATFORM_SOCKET socket = itermap->first;
|
||||
if (FD_ISSET(socket, &rfds))
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s] FD_ISSET true for socket %d...\n",__FUNCTION__,socket);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s] FD_ISSET true for socket %d...\n",__FUNCTION__,socket);
|
||||
|
||||
itermap->second = true;
|
||||
}
|
||||
@@ -911,7 +912,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socketTriggeredList->size() = %d\n",__FILE__,__FUNCTION__,socketTriggeredList.size());
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] socketTriggeredList->size() = %d\n",__FILE__,__FUNCTION__,socketTriggeredList.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1040,6 +1041,7 @@ int Socket::send(const void *data, int dataSize) {
|
||||
#else
|
||||
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
#endif
|
||||
safeMutex.ReleaseLock();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
@@ -1072,13 +1074,13 @@ int Socket::send(const void *data, int dataSize) {
|
||||
#else
|
||||
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
#endif
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
|
||||
|
||||
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
break;
|
||||
}
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during send, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
|
||||
}
|
||||
else {
|
||||
int iErr = getLastSocketError();
|
||||
@@ -1114,16 +1116,17 @@ int Socket::send(const void *data, int dataSize) {
|
||||
#else
|
||||
bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
#endif
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
if(bytesSent > 0) {
|
||||
totalBytesSent += bytesSent;
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] retry send returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
|
||||
|
||||
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
break;
|
||||
}
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] retry send returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent);
|
||||
}
|
||||
else {
|
||||
int iErr = getLastSocketError();
|
||||
@@ -1168,6 +1171,7 @@ int Socket::receive(void *data, int dataSize) {
|
||||
if(isSocketValid() == true) {
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText().c_str());
|
||||
@@ -1221,6 +1225,7 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) {
|
||||
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
|
||||
|
||||
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
|
||||
}
|
||||
@@ -1321,6 +1326,7 @@ bool Socket::isReadable() {
|
||||
{
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
i= select((int)sock + 1, &set, NULL, NULL, &tv);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
if(i < 0) {
|
||||
//if(difftime(time(NULL),lastDebugEvent) >= 1) {
|
||||
@@ -1359,6 +1365,7 @@ bool Socket::isWritable(bool waitOnDelayedResponse) {
|
||||
{
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
i = select((int)sock + 1, NULL, &set, NULL, &tv);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
if(i < 0 ) {
|
||||
//if(difftime(time(NULL),lastDebugEvent) >= 1) {
|
||||
@@ -1541,6 +1548,7 @@ void ClientSocket::connect(const Ip &ip, int port)
|
||||
{
|
||||
MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
err = select((int)sock + 1, NULL, &myset, NULL, &tv);
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
if (err < 0 && getLastSocketError() != PLATFORM_SOCKET_INTERRUPTED) {
|
||||
|
Reference in New Issue
Block a user