Skip to content
Permalink
Browse files

[Port from Experimental: 07-01-2019, Nolok] Fixed: PacketDeathAnimati…

…on setting on sphere.ini making some client versions crash

[Port from Experimental: 07-01-2019, Nolok] Fixed: ScreenSize packet incorrectly parsing received data
  • Loading branch information...
coruja747 committed Jan 10, 2019
1 parent 5c9d97b commit 2150dd3197bb19051b2b63fe7a9eed5056028d53
@@ -1334,4 +1334,8 @@ Changed: Updated REPAIR function on craft skills.
[items/sphere_item_artifacts.scp]: Misc improvements and added new Artifacts of the Cult
[items/sphere_item_artifacts_minor.scp]: Misc improvements
[items/sphere_item_artifacts_tokuno.scp]: Misc improvements
[items/sphere_item_magic_wands.scp]: Removed unused file
[items/sphere_item_magic_wands.scp]: Removed unused file

10-01-2019, Coruja
[Port from Experimental: 07-01-2019, Nolok] Fixed: PacketDeathAnimation setting on sphere.ini making some client versions crash.
[Port from Experimental: 07-01-2019, Nolok] Fixed: ScreenSize packet incorrectly parsing received data.
@@ -2696,7 +2696,7 @@ bool CChar::Death()
StatFlag_Set(STATF_Insubstantial);
StatFlag_Clear(STATF_War);

m_pPlayer->m_wDeaths++;
++m_pPlayer->m_wDeaths;
SetHue(HUE_DEFAULT); // get all pale
SetID(static_cast<CREID_TYPE>(g_Cfg.ResourceGetIndexType(RES_CHARDEF, pszGhostName)));
LayerAdd(CItem::CreateScript(ITEMID_DEATHSHROUD, this));
@@ -2706,17 +2706,16 @@ bool CChar::Death()
if ( g_Cfg.m_iPacketDeathAnimation || m_pClient->m_NetState->isClientKR() || m_pClient->m_NetState->isClientEnhanced() )
{
// Display the "You are dead" screen animation (this must be always enabled on enhanced clients)
new PacketDeathMenu(m_pClient, PacketDeathMenu::ServerSent);
new PacketDeathMenu(m_pClient, PacketDeathMenu::Ghost);
new PacketDeathMenu(m_pClient, DEATH_MODE_MANIFEST);
}
else
{
// OSI uses PacketDeathMenu to update client screen on death. If this packet is disabled,
// the client must be updated manually using these others packets as workaround
m_pClient->addPlayerUpdate();
m_pClient->addPlayerWarMode();
}

m_pClient->addPlayerWarMode();
m_pClient->addSeason(SEASON_Desolate);
m_pClient->addMapWaypoint(pCorpse, Corpse); // add corpse map waypoint on enhanced clients

@@ -66,8 +66,8 @@ CClient::CClient(NetState *state)
#else
HistoryIP &history = g_NetworkIn.getIPHistoryManager().getHistoryForIP(GetPeer());
#endif
history.m_connecting++;
history.m_connected++;
++history.m_connecting;
++history.m_connected;

g_Log.Event(LOGM_CLIENTS_LOG, "%lx:Client connected [Total:%lu] ('%s' %ld/%ld)\n", GetSocketID(), g_Serv.StatGet(SERV_STAT_CLIENTS), GetPeerStr(), history.m_connecting, history.m_connected);
}
@@ -752,7 +752,7 @@ bool CClient::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
break;
case CC_REPORTEDCLIVER:
{
pszKey += strlen(sm_szLoadKeys[index]);
pszKey += 14;
GETNONWHITESPACE(pszKey);

DWORD dwCliVer = m_NetState->getReportedVersion();
@@ -773,18 +773,18 @@ bool CClient::r_WriteVal(LPCTSTR pszKey, CGString &sVal, CTextConsole *pSrc)
{
if ( pszKey[10] == '.' )
{
pszKey += strlen(sm_szLoadKeys[index]);
pszKey += 10;
SKIP_SEPARATORS(pszKey);

if ( !strnicmp("X", pszKey, 1) )
sVal.Format("%lu", m_ScreenSize.x);
sVal.Format("%hu", m_ScreenSize.x);
else if ( !strnicmp("Y", pszKey, 1) )
sVal.Format("%lu", m_ScreenSize.y);
sVal.Format("%hu", m_ScreenSize.y);
else
return false;
}
else
sVal.Format("%lu,%lu", m_ScreenSize.x, m_ScreenSize.y);
sVal.Format("%hu,%hu", m_ScreenSize.x, m_ScreenSize.y);
break;
}
case CC_TARG:
@@ -381,8 +381,8 @@ class CClient : public CGObListRec, public CScriptObj, public CChatMember, publi
// Screensize
struct __screensize
{
DWORD x;
DWORD y;
WORD x;
WORD y;
} m_ScreenSize;

// Promptconsole
@@ -873,7 +873,7 @@ class CClient : public CGObListRec, public CScriptObj, public CChatMember, publi
return false;
}

void SetScreenSize(DWORD x, DWORD y)
void SetScreenSize(WORD x, WORD y)
{
m_ScreenSize.x = x;
m_ScreenSize.y = y;
@@ -886,7 +886,6 @@ bool PacketResynchronize::onReceive(NetState* net)
new PacketCharacter(client, pChar);
client->addPlayerUpdate();
client->addPlayerSee(NULL);
net->m_sequence = 0;
return true;
}

@@ -902,49 +901,24 @@ PacketDeathStatus::PacketDeathStatus() : Packet(2)
{
}

size_t PacketDeathStatus::getExpectedLength(NetState* net, Packet* packet)
{
ADDTOCALLSTACK("PacketDeathStatus::getExpectedLength");
UNREFERENCED_PARAMETER(net);

// different size depending on client
size_t pos = packet->getPosition();
packet->skip(1);
DEATH_MODE_TYPE mode = static_cast<DEATH_MODE_TYPE>(readByte());
packet->seek(pos);

if (mode != DEATH_MODE_MANIFEST)
return 2;

return 7;
}

bool PacketDeathStatus::onReceive(NetState* net)
{
ADDTOCALLSTACK("PacketDeathStatus::onReceive");
ADDTOCALLSTACK("PacketDeathStatus::onReceive");

CClient* client = net->m_client;
ASSERT(client);
CChar* ghost = client->GetChar();
if (!ghost)
return false;

DEATH_MODE_TYPE mode = static_cast<DEATH_MODE_TYPE>(readByte());
BYTE mode = readByte();
if (mode != DEATH_MODE_MANIFEST)
{
// Play as a ghost.
client->SysMessage("You are a ghost");
client->addSound(0x17f);
client->addPlayerStart(ghost); // Do practically a full reset (to clear death menu)
return true;
}

// toggle manifest mode (more data)
skip(1); // unknown
bool manifest = readBool();
skip(3); // unknown

client->Event_CombatMode(manifest);
return true;
}

@@ -2216,7 +2190,7 @@ bool PacketSystemInfo::onReceive(NetState* net)
ADDTOCALLSTACK("PacketSystemInfo::onReceive");
UNREFERENCED_PARAMETER(net);

skip(148);
// Ignore this packet
return true;
}

@@ -2813,11 +2787,11 @@ bool PacketScreenSize::onReceive(NetState* net)
CClient* client = net->m_client;
ASSERT(client);

DWORD x = readInt32();
DWORD y = readInt32();
skip(2);
WORD x = readInt16();
WORD y = readInt16();
skip(2);

DEBUG_MSG(("0x%lx - 0x%lx (%ld-%ld)\n", x, y, x, y));

client->SetScreenSize(x, y);
return true;
}
@@ -3050,6 +3024,7 @@ bool PacketStatusClose::onReceive(NetState* net)
ADDTOCALLSTACK("PacketStatusClose::onReceive");
UNREFERENCED_PARAMETER(net);

// Ignore this packet
return true;
}

@@ -3119,8 +3094,7 @@ bool PacketClientInfo::onReceive(NetState* net)
ADDTOCALLSTACK("PacketClientInfo::onReceive");
UNREFERENCED_PARAMETER(net);

skip(1); // 0x0A
skip(4); // flags
// Ignore this packet
return true;
}

@@ -3358,6 +3332,7 @@ bool PacketAntiCheat::onReceive(NetState* net)
ADDTOCALLSTACK("PacketAntiCheat::onReceive");
UNREFERENCED_PARAMETER(net);

// Ignore this packet
return true;
}

@@ -4259,32 +4234,7 @@ bool PacketHardwareInfo::onReceive(NetState* net)
ADDTOCALLSTACK("PacketHardwareInfo::onReceive");
UNREFERENCED_PARAMETER(net);

skip(1); // client type
skip(4); // instance id
skip(4); // os major
skip(4); // os minor
skip(4); // os revision
skip(1); // cpu manufacturer
skip(4); // cpu family
skip(4); // cpu model
skip(4); // cpu clock speed
skip(1); // cpu quantity
skip(4); // physical memory
skip(4); // screen width
skip(4); // screen height
skip(4); // screen depth
skip(2); // directx major
skip(2); // directx minor
skip(64 * sizeof(WCHAR)); // video card description
skip(4); // video card vendor id
skip(4); // video card device id
skip(4); // video card memory
skip(1); // distribution
skip(1); // clients running
skip(1); // clients installed
skip(1); // clients partial installed
skip(4 * sizeof(WCHAR)); // language
skip(32 * sizeof(WCHAR)); // unknown
// Ignore this packet
return true;
}

@@ -4364,11 +4314,7 @@ bool PacketRemoveUIHighlight::onReceive(NetState* net)
ADDTOCALLSTACK("PacketRemoveUIHighlight::onReceive");
UNREFERENCED_PARAMETER(net);

skip(4); // serial
skip(2); // ui id
skip(4); // destination serial
skip(1); // 1
skip(1); // 1
// Ignore this packet
return true;
}

@@ -189,7 +189,6 @@ class PacketDeathStatus : public Packet
{
public:
PacketDeathStatus();
virtual size_t getExpectedLength(NetState* client, Packet* packet);
virtual bool onReceive(NetState* net);
};

@@ -957,11 +957,11 @@ PacketDropAccepted::PacketDropAccepted(const CClient* target) : PacketSend(XCMD_
*
*
***************************************************************************/
PacketDeathMenu::PacketDeathMenu(const CClient* target, Reason reason) : PacketSend(XCMD_DeathMenu, 2, PRI_NORMAL)
PacketDeathMenu::PacketDeathMenu(const CClient *target, BYTE mode) : PacketSend(XCMD_DeathMenu, 2, PRI_NORMAL)
{
ADDTOCALLSTACK("PacketDeathMenu::PacketDeathMenu");

writeByte(static_cast<BYTE>(reason));
writeByte(mode);
push(target);
}

@@ -351,14 +351,7 @@ class PacketDropAccepted : public PacketSend
class PacketDeathMenu : public PacketSend
{
public:
enum Reason
{
ServerSent = 0x0,
Resurrect = 0x1,
Ghost = 0x2
};

PacketDeathMenu(const CClient* target, Reason reason);
PacketDeathMenu(const CClient *target, BYTE mode);
};

/***************************************************************************

0 comments on commit 2150dd3

Please sign in to comment.
You can’t perform that action at this time.