mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-10-12 02:13:06 +00:00
Don't send spell level in spell casting network message
This commit is contained in:
+4
-5
@@ -2524,17 +2524,16 @@ bool TryIconCurs()
|
||||
if (pcurs == CURSOR_TELEPORT) {
|
||||
const SpellID spellID = myPlayer.inventorySpell;
|
||||
const SpellType spellType = SpellType::Scroll;
|
||||
const int spellLevel = myPlayer.GetSpellLevel(spellID);
|
||||
const int spellFrom = myPlayer.spellFrom;
|
||||
if (IsWallSpell(spellID)) {
|
||||
Direction sd = GetDirection(myPlayer.position.tile, cursPosition);
|
||||
NetSendCmdLocParam5(true, CMD_SPELLXYD, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellLevel, spellFrom);
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXYD, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellFrom);
|
||||
} else if (pcursmonst != -1) {
|
||||
NetSendCmdParam5(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
|
||||
NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
|
||||
} else if (pcursplr != -1 && !myPlayer.friendlyMode) {
|
||||
NetSendCmdParam5(true, CMD_SPELLPID, pcursplr, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
|
||||
NetSendCmdParam4(true, CMD_SPELLPID, pcursplr, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
|
||||
} else {
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
|
||||
NetSendCmdLocParam3(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
|
||||
}
|
||||
NewCursor(CURSOR_HAND);
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -4110,7 +4110,7 @@ void UseItem(size_t pnum, item_misc_id mid, SpellID spellID, int spellFrom)
|
||||
target = player.position.future + Displacement(player._pdir);
|
||||
// Use CMD_SPELLXY because it's the same behavior as normal casting
|
||||
assert(IsValidSpellFrom(spellFrom));
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXY, target, static_cast<int8_t>(spellID), static_cast<uint8_t>(SpellType::Scroll), spellLevel, static_cast<uint16_t>(spellFrom));
|
||||
NetSendCmdLocParam3(true, CMD_SPELLXY, target, static_cast<int8_t>(spellID), static_cast<uint8_t>(SpellType::Scroll), static_cast<uint16_t>(spellFrom));
|
||||
}
|
||||
break;
|
||||
case IMISC_BOOK: {
|
||||
|
||||
+14
-38
@@ -1454,7 +1454,7 @@ bool InitNewSpell(Player &player, uint16_t wParamSpellID, uint16_t wParamSpellTy
|
||||
|
||||
size_t OnSpellWall(const TCmd *pCmd, Player &player)
|
||||
{
|
||||
const auto &message = *reinterpret_cast<const TCmdLocParam5 *>(pCmd);
|
||||
const auto &message = *reinterpret_cast<const TCmdLocParam4 *>(pCmd);
|
||||
const Point position { message.x, message.y };
|
||||
|
||||
if (gbBufferMsgs == 1)
|
||||
@@ -1467,7 +1467,7 @@ size_t OnSpellWall(const TCmd *pCmd, Player &player)
|
||||
if (wParamDirection > static_cast<uint16_t>(Direction::SouthEast))
|
||||
return sizeof(message);
|
||||
|
||||
if (!InitNewSpell(player, message.wParam1, message.wParam2, message.wParam5))
|
||||
if (!InitNewSpell(player, message.wParam1, message.wParam2, message.wParam4))
|
||||
return sizeof(message);
|
||||
|
||||
ClrPlrPath(player);
|
||||
@@ -1475,14 +1475,14 @@ size_t OnSpellWall(const TCmd *pCmd, Player &player)
|
||||
player.destParam1 = position.x;
|
||||
player.destParam2 = position.y;
|
||||
player.destParam3 = wParamDirection;
|
||||
player.destParam4 = SDL_SwapLE16(message.wParam4); // Spell Level
|
||||
player.destParam4 = player.GetSpellLevel(player.queuedSpell.spellId);
|
||||
|
||||
return sizeof(message);
|
||||
}
|
||||
|
||||
size_t OnSpellTile(const TCmd *pCmd, Player &player)
|
||||
{
|
||||
const auto &message = *reinterpret_cast<const TCmdLocParam4 *>(pCmd);
|
||||
const auto &message = *reinterpret_cast<const TCmdLocParam3 *>(pCmd);
|
||||
const Point position { message.x, message.y };
|
||||
|
||||
if (gbBufferMsgs == 1)
|
||||
@@ -1492,14 +1492,14 @@ size_t OnSpellTile(const TCmd *pCmd, Player &player)
|
||||
if (!InDungeonBounds(position))
|
||||
return sizeof(message);
|
||||
|
||||
if (!InitNewSpell(player, message.wParam1, message.wParam2, message.wParam4))
|
||||
if (!InitNewSpell(player, message.wParam1, message.wParam2, message.wParam3))
|
||||
return sizeof(message);
|
||||
|
||||
ClrPlrPath(player);
|
||||
player.destAction = ACTION_SPELL;
|
||||
player.destParam1 = position.x;
|
||||
player.destParam2 = position.y;
|
||||
player.destParam3 = SDL_SwapLE16(message.wParam3); // Spell Level
|
||||
player.destParam3 = player.GetSpellLevel(player.queuedSpell.spellId);
|
||||
|
||||
return sizeof(message);
|
||||
}
|
||||
@@ -1581,7 +1581,7 @@ size_t OnRangedAttackPlayer(const TCmd *pCmd, Player &player)
|
||||
|
||||
size_t OnSpellMonster(const TCmd *pCmd, Player &player)
|
||||
{
|
||||
const auto &message = *reinterpret_cast<const TCmdParam5 *>(pCmd);
|
||||
const auto &message = *reinterpret_cast<const TCmdParam4 *>(pCmd);
|
||||
|
||||
if (gbBufferMsgs == 1)
|
||||
return sizeof(message);
|
||||
@@ -1591,20 +1591,20 @@ size_t OnSpellMonster(const TCmd *pCmd, Player &player)
|
||||
if (monsterIdx >= MaxMonsters)
|
||||
return sizeof(message);
|
||||
|
||||
if (!InitNewSpell(player, message.wParam2, message.wParam3, message.wParam5))
|
||||
if (!InitNewSpell(player, message.wParam2, message.wParam3, message.wParam4))
|
||||
return sizeof(message);
|
||||
|
||||
ClrPlrPath(player);
|
||||
player.destAction = ACTION_SPELLMON;
|
||||
player.destParam1 = monsterIdx;
|
||||
player.destParam2 = SDL_SwapLE16(message.wParam4); // Spell Level
|
||||
player.destParam2 = player.GetSpellLevel(player.queuedSpell.spellId);
|
||||
|
||||
return sizeof(message);
|
||||
}
|
||||
|
||||
size_t OnSpellPlayer(const TCmd *pCmd, Player &player)
|
||||
{
|
||||
const auto &message = *reinterpret_cast<const TCmdParam5 *>(pCmd);
|
||||
const auto &message = *reinterpret_cast<const TCmdParam4 *>(pCmd);
|
||||
|
||||
if (gbBufferMsgs == 1)
|
||||
return sizeof(message);
|
||||
@@ -1614,13 +1614,13 @@ size_t OnSpellPlayer(const TCmd *pCmd, Player &player)
|
||||
if (playerIdx >= Players.size())
|
||||
return sizeof(message);
|
||||
|
||||
if (!InitNewSpell(player, message.wParam2, message.wParam3, message.wParam5))
|
||||
if (!InitNewSpell(player, message.wParam2, message.wParam3, message.wParam4))
|
||||
return sizeof(message);
|
||||
|
||||
ClrPlrPath(player);
|
||||
player.destAction = ACTION_SPELLPLR;
|
||||
player.destParam1 = playerIdx;
|
||||
player.destParam2 = SDL_SwapLE16(message.wParam4); // Spell Level
|
||||
player.destParam2 = player.GetSpellLevel(player.queuedSpell.spellId);
|
||||
|
||||
return sizeof(message);
|
||||
}
|
||||
@@ -2908,29 +2908,6 @@ void NetSendCmdLocParam4(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wPa
|
||||
MyPlayer->UpdatePreviewCelSprite(bCmd, position, wParam1, wParam3);
|
||||
}
|
||||
|
||||
void NetSendCmdLocParam5(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4, uint16_t wParam5)
|
||||
{
|
||||
if (WasPlayerCmdAlreadyRequested(bCmd, position, wParam1, wParam2, wParam3, wParam4, wParam5))
|
||||
return;
|
||||
|
||||
TCmdLocParam5 cmd;
|
||||
|
||||
cmd.bCmd = bCmd;
|
||||
cmd.x = position.x;
|
||||
cmd.y = position.y;
|
||||
cmd.wParam1 = SDL_SwapLE16(wParam1);
|
||||
cmd.wParam2 = SDL_SwapLE16(wParam2);
|
||||
cmd.wParam3 = SDL_SwapLE16(wParam3);
|
||||
cmd.wParam4 = SDL_SwapLE16(wParam4);
|
||||
cmd.wParam5 = SDL_SwapLE16(wParam5);
|
||||
if (bHiPri)
|
||||
NetSendHiPri(MyPlayerId, (byte *)&cmd, sizeof(cmd));
|
||||
else
|
||||
NetSendLoPri(MyPlayerId, (byte *)&cmd, sizeof(cmd));
|
||||
|
||||
MyPlayer->UpdatePreviewCelSprite(bCmd, position, wParam1, wParam3);
|
||||
}
|
||||
|
||||
void NetSendCmdParam1(bool bHiPri, _cmd_id bCmd, uint16_t wParam1)
|
||||
{
|
||||
if (WasPlayerCmdAlreadyRequested(bCmd, {}, wParam1))
|
||||
@@ -2961,19 +2938,18 @@ void NetSendCmdParam2(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wPar
|
||||
NetSendLoPri(MyPlayerId, (byte *)&cmd, sizeof(cmd));
|
||||
}
|
||||
|
||||
void NetSendCmdParam5(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4, uint16_t wParam5)
|
||||
void NetSendCmdParam4(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4)
|
||||
{
|
||||
if (WasPlayerCmdAlreadyRequested(bCmd, {}, wParam1, wParam2, wParam3, wParam4))
|
||||
return;
|
||||
|
||||
TCmdParam5 cmd;
|
||||
TCmdParam4 cmd;
|
||||
|
||||
cmd.bCmd = bCmd;
|
||||
cmd.wParam1 = SDL_SwapLE16(wParam1);
|
||||
cmd.wParam2 = SDL_SwapLE16(wParam2);
|
||||
cmd.wParam3 = SDL_SwapLE16(wParam3);
|
||||
cmd.wParam4 = SDL_SwapLE16(wParam4);
|
||||
cmd.wParam5 = SDL_SwapLE16(wParam5);
|
||||
if (bHiPri)
|
||||
NetSendHiPri(MyPlayerId, (byte *)&cmd, sizeof(cmd));
|
||||
else
|
||||
|
||||
+2
-4
@@ -495,13 +495,12 @@ struct TCmdParam2 {
|
||||
uint16_t wParam2;
|
||||
};
|
||||
|
||||
struct TCmdParam5 {
|
||||
struct TCmdParam4 {
|
||||
_cmd_id bCmd;
|
||||
uint16_t wParam1;
|
||||
uint16_t wParam2;
|
||||
uint16_t wParam3;
|
||||
uint16_t wParam4;
|
||||
uint16_t wParam5;
|
||||
};
|
||||
|
||||
struct TCmdGolem {
|
||||
@@ -748,10 +747,9 @@ void NetSendCmdLocParam1(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wPa
|
||||
void NetSendCmdLocParam2(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1, uint16_t wParam2);
|
||||
void NetSendCmdLocParam3(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3);
|
||||
void NetSendCmdLocParam4(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4);
|
||||
void NetSendCmdLocParam5(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4, uint16_t wParam5);
|
||||
void NetSendCmdParam1(bool bHiPri, _cmd_id bCmd, uint16_t wParam1);
|
||||
void NetSendCmdParam2(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wParam2);
|
||||
void NetSendCmdParam5(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4, uint16_t wParam5);
|
||||
void NetSendCmdParam4(bool bHiPri, _cmd_id bCmd, uint16_t wParam1, uint16_t wParam2, uint16_t wParam3, uint16_t wParam4);
|
||||
void NetSendCmdQuest(bool bHiPri, const Quest &quest);
|
||||
void NetSendCmdGItem(bool bHiPri, _cmd_id bCmd, uint8_t pnum, uint8_t ii);
|
||||
void NetSendCmdPItem(bool bHiPri, _cmd_id bCmd, Point position, const Item &item);
|
||||
|
||||
+4
-9
@@ -1308,22 +1308,18 @@ void CheckNewPath(Player &player, bool pmWillBeCalled)
|
||||
case ACTION_SPELL:
|
||||
d = GetDirection(player.position.tile, { player.destParam1, player.destParam2 });
|
||||
StartSpell(player, d, player.destParam1, player.destParam2);
|
||||
player.executedSpell.spellLevel = player.destParam3;
|
||||
break;
|
||||
case ACTION_SPELLWALL:
|
||||
StartSpell(player, static_cast<Direction>(player.destParam3), player.destParam1, player.destParam2);
|
||||
player.tempDirection = static_cast<Direction>(player.destParam3);
|
||||
player.executedSpell.spellLevel = player.destParam4;
|
||||
break;
|
||||
case ACTION_SPELLMON:
|
||||
d = GetDirection(player.position.tile, monster->position.future);
|
||||
StartSpell(player, d, monster->position.future.x, monster->position.future.y);
|
||||
player.executedSpell.spellLevel = player.destParam2;
|
||||
break;
|
||||
case ACTION_SPELLPLR:
|
||||
d = GetDirection(player.position.tile, target->position.future);
|
||||
StartSpell(player, d, target->position.future.x, target->position.future.y);
|
||||
player.executedSpell.spellLevel = player.destParam2;
|
||||
break;
|
||||
case ACTION_OPERATE:
|
||||
if (IsPlayerAdjacentToObject(player, *object)) {
|
||||
@@ -3235,21 +3231,20 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType)
|
||||
return;
|
||||
}
|
||||
|
||||
const int spellLevel = myPlayer.GetSpellLevel(spellID);
|
||||
const int spellFrom = 0;
|
||||
if (IsWallSpell(spellID)) {
|
||||
LastMouseButtonAction = MouseActionType::Spell;
|
||||
Direction sd = GetDirection(myPlayer.position.tile, cursPosition);
|
||||
NetSendCmdLocParam5(true, CMD_SPELLXYD, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellLevel, spellFrom);
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXYD, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellFrom);
|
||||
} else if (pcursmonst != -1 && !isShiftHeld) {
|
||||
LastMouseButtonAction = MouseActionType::SpellMonsterTarget;
|
||||
NetSendCmdParam5(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
|
||||
NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
|
||||
} else if (pcursplr != -1 && !isShiftHeld && !myPlayer.friendlyMode) {
|
||||
LastMouseButtonAction = MouseActionType::SpellPlayerTarget;
|
||||
NetSendCmdParam5(true, CMD_SPELLPID, pcursplr, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
|
||||
NetSendCmdParam4(true, CMD_SPELLPID, pcursplr, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
|
||||
} else {
|
||||
LastMouseButtonAction = MouseActionType::Spell;
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
|
||||
NetSendCmdLocParam3(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellFrom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user