Skip to content
Closed

awol #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/GameNetwork/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ UnsignedInt Connection::doSend() {
m_lastTimeSent = curtime;
}
if (packet != NULL) {
deleteInstance(packet); // delete the packet now that we're done with it.
// deleteInstance(packet); // delete the packet now that we're done with it.
}
}

Expand Down
8 changes: 6 additions & 2 deletions Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include "../NextGenTransport.h"
#include "../NetworkMesh.h"
#include "../ngmp_interfaces.h"
#include <thread>
#include <chrono>

extern Int MIN_LOGIC_FRAMES;

Expand Down Expand Up @@ -1675,7 +1677,7 @@ void ConnectionManager::sendLocalCommandDirect(NetCommandMsg *msg, UnsignedByte
}
}

msg->detach();
// msg->detach();
}

Int commandsReadyDebugSpewage = 0;
Expand Down Expand Up @@ -1935,6 +1937,7 @@ void ConnectionManager::quitGame() {
NetDisconnectPlayerCommandMsg *disconnectMsg = newInstance(NetDisconnectPlayerCommandMsg);
disconnectMsg->setDisconnectSlot(m_localSlot);
disconnectMsg->setDisconnectFrame(TheGameLogic->getFrame());
disconnectMsg->attach();
disconnectMsg->setPlayerID(m_localSlot);
if (DoesCommandRequireACommandID(disconnectMsg->getNetCommandType())) {
disconnectMsg->setID(GenerateNextCommandID());
Expand All @@ -1944,9 +1947,10 @@ void ConnectionManager::quitGame() {

//DEBUG_LOG(("ConnectionManager::disconnectLocalPlayer - about to flush connections"));
flushConnections(); // need to do this so our packet actually gets sent before the connections are deleted.
std::this_thread::sleep_for(std::chrono::milliseconds(50));
//DEBUG_LOG(("ConnectionManager::disconnectLocalPlayer - done flushing connections"));

disconnectMsg->detach();
// disconnectMsg->detach();

#if RTS_GENERALS
// if we get here, we hit Quit on the disconnect screen. Mark everyone as having disconnected from us
Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ void DisconnectManager::sendDisconnectCommand(Int slot, ConnectionManager *conMg
msg->setDisconnectSlot(slot);
msg->setDisconnectFrame(disconnectFrame);
msg->setPlayerID(conMgr->getLocalPlayerID());
msg->attach();
if (DoesCommandRequireACommandID(msg->getNetCommandType())) {
msg->setID(GenerateNextCommandID());
}
Expand Down
38 changes: 20 additions & 18 deletions Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
////////////////////////////////////////////////////////////////////////////////


#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine

#include "GameNetwork/NetCommandMsg.h"
#include "Common/GameState.h"
Expand All @@ -33,7 +33,7 @@
/**
* Base constructor
*/
NetCommandMsg::NetCommandMsg()
NetCommandMsg::NetCommandMsg()
{
m_executionFrame = 0;
m_id = 0;
Expand Down Expand Up @@ -123,10 +123,10 @@ NetGameCommandMsg::~NetGameCommandMsg() {
/**
* Add an argument to this command.
*/
void NetGameCommandMsg::addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg)
void NetGameCommandMsg::addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg)
{
if (m_argTail == NULL) {
m_argList = newInstance(GameMessageArgument);
m_argList = newInstance(GameMessageArgument);
m_argTail = m_argList;
m_argList->m_data = arg;
m_argList->m_type = type;
Expand All @@ -153,15 +153,15 @@ static Int indexFromMask(UnsignedInt mask)
player = ThePlayerList->getNthPlayer( i );
if( player && player->getPlayerMask() == mask )
return i;
}
}

return -1;
}

/**
* Construct a new GameMessage object from the data in this object.
*/
GameMessage *NetGameCommandMsg::constructGameMessage()
GameMessage *NetGameCommandMsg::constructGameMessage()
{
GameMessage *retval = newInstance(GameMessage)(m_type);

Expand Down Expand Up @@ -600,6 +600,7 @@ NetDisconnectKeepAliveCommandMsg::~NetDisconnectKeepAliveCommandMsg() {
NetDisconnectPlayerCommandMsg::NetDisconnectPlayerCommandMsg() : NetCommandMsg() {
m_commandType = NETCOMMANDTYPE_DISCONNECTPLAYER;
m_disconnectSlot = 0;
m_disconnectFrame = 0;
}

/**
Expand Down Expand Up @@ -804,7 +805,7 @@ NetProgressCommandMsg::NetProgressCommandMsg( void ) : NetCommandMsg()
}

NetProgressCommandMsg::~NetProgressCommandMsg( void ) {}

UnsignedByte NetProgressCommandMsg::getPercentage()
{
return m_percent;
Expand All @@ -830,17 +831,17 @@ NetWrapperCommandMsg::NetWrapperCommandMsg() : NetCommandMsg() {
}

NetWrapperCommandMsg::~NetWrapperCommandMsg() {
delete m_data;
m_data = NULL;
delete m_data;
m_data = NULL;
}

UnsignedByte * NetWrapperCommandMsg::getData() {
return m_data;
}

void NetWrapperCommandMsg::setData(UnsignedByte *data, UnsignedInt dataLength)
void NetWrapperCommandMsg::setData(UnsignedByte *data, UnsignedInt dataLength)
{
delete m_data;
delete m_data;
m_data = NEW UnsignedByte[dataLength]; // pool[]ify
memcpy(m_data, data, dataLength);
m_dataLength = dataLength;
Expand Down Expand Up @@ -901,16 +902,16 @@ NetFileCommandMsg::NetFileCommandMsg() : NetCommandMsg() {
}

NetFileCommandMsg::~NetFileCommandMsg() {
delete[] m_data;
m_data = NULL;
delete[] m_data;
m_data = NULL;
}

AsciiString NetFileCommandMsg::getRealFilename()
AsciiString NetFileCommandMsg::getRealFilename()
{
return TheGameState->portableMapPathToRealMapPath(m_portableFilename);
}

void NetFileCommandMsg::setRealFilename(AsciiString filename)
void NetFileCommandMsg::setRealFilename(AsciiString filename)
{
m_portableFilename = TheGameState->realMapPathToPortableMapPath(filename);
}
Expand All @@ -923,7 +924,7 @@ UnsignedByte * NetFileCommandMsg::getFileData() {
return m_data;
}

void NetFileCommandMsg::setFileData(UnsignedByte *data, UnsignedInt dataLength)
void NetFileCommandMsg::setFileData(UnsignedByte *data, UnsignedInt dataLength)
{
m_dataLength = dataLength;
m_data = NEW UnsignedByte[dataLength]; // pool[]ify
Expand All @@ -943,12 +944,12 @@ NetFileAnnounceCommandMsg::NetFileAnnounceCommandMsg() : NetCommandMsg() {
NetFileAnnounceCommandMsg::~NetFileAnnounceCommandMsg() {
}

AsciiString NetFileAnnounceCommandMsg::getRealFilename()
AsciiString NetFileAnnounceCommandMsg::getRealFilename()
{
return TheGameState->portableMapPathToRealMapPath(m_portableFilename);
}

void NetFileAnnounceCommandMsg::setRealFilename(AsciiString filename)
void NetFileAnnounceCommandMsg::setRealFilename(AsciiString filename)
{
m_portableFilename = TheGameState->realMapPathToPortableMapPath(filename);
}
Expand Down Expand Up @@ -1054,3 +1055,4 @@ UnsignedInt NetFrameResendRequestCommandMsg::getFrameToResend() {
void NetFrameResendRequestCommandMsg::setFrameToResend(UnsignedInt frame) {
m_frameToResend = frame;
}

Loading