Skip to content

Commit

Permalink
fix (multiplayer): blink targeted unit only for player issuing command
Browse files Browse the repository at this point in the history
  • Loading branch information
codeflorist committed May 13, 2023
1 parent b6ef892 commit 63fd5e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/net/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ Client_Recv_UpdateUnits(const unsigned char **buf)
u->orientation[1].current = Net_Decode_uint8(buf);
u->wobbleIndex = Net_Decode_uint8(buf);
u->spriteOffset = Net_Decode_uint8(buf);
u->blinkHouse = Net_Decode_uint8(buf);

/* XXX -- Smooth animation not yet implemented. */
u->lastPosition = o->position;
Expand Down
11 changes: 8 additions & 3 deletions src/net/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef struct UnitDelta {
int8 orientation1_current;
uint8 wobbleIndex;
uint8 spriteOffset;
uint8 blinkHouse;
} UnitDelta;

static Tile s_mapCopy[MAP_SIZE_MAX * MAP_SIZE_MAX];
Expand Down Expand Up @@ -193,6 +194,7 @@ Server_InitUnitDelta(const Unit *u, UnitDelta *d)
d->orientation1_current = u->orientation[1].current;
d->wobbleIndex = u->wobbleIndex;
d->spriteOffset = u->spriteOffset;
d->blinkHouse = u->blinkHouse;
}

void
Expand Down Expand Up @@ -417,7 +419,7 @@ void
Server_Send_UpdateUnits(unsigned char **buf)
{
const size_t header_len = 1 + 1;
const size_t element_len = 2 + 12 + 9;
const size_t element_len = 2 + 12 + 10;
const int max = Server_MaxElementsToEncode(buf, header_len, element_len);

if (max <= 0)
Expand Down Expand Up @@ -450,7 +452,7 @@ Server_Send_UpdateUnits(unsigned char **buf)
Net_Encode_uint16(buf, d.position.y);
Net_Encode_uint16(buf, d.hitpoints);

/* 9 bytes. */
/* 10 bytes. */
Net_Encode_uint8 (buf, d.actionID);
Net_Encode_uint8 (buf, d.nextActionID);
Net_Encode_uint8 (buf, d.amount);
Expand All @@ -460,6 +462,7 @@ Server_Send_UpdateUnits(unsigned char **buf)
Net_Encode_uint8 (buf, d.orientation1_current);
Net_Encode_uint8 (buf, d.wobbleIndex);
Net_Encode_uint8 (buf, d.spriteOffset);
Net_Encode_uint8 (buf, d.blinkHouse);

count++;
}
Expand Down Expand Up @@ -1298,8 +1301,10 @@ Server_Recv_IssueUnitActionTargetted(Unit *u,
target = Tools_Index_GetUnit(u->targetAttack);
}

if (target != NULL)
if (target != NULL) {
target->blinkCounter = 8;
target->blinkHouse = Unit_GetHouseID(u);
}
}

static void
Expand Down
2 changes: 1 addition & 1 deletion src/newui/viewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ Viewport_DrawUnit(const Unit *u, int windowX, int windowY, bool render_for_blur_
s_spriteFlags = 0;
}

if (u->o.type != UNIT_SANDWORM && u->o.flags.s.isHighlighted) s_spriteFlags |= 0x100;
if (u->o.type != UNIT_SANDWORM && u->o.flags.s.isHighlighted && u->blinkHouse == g_playerHouseID) s_spriteFlags |= 0x100;

bool isWobbling = true;

Expand Down
1 change: 1 addition & 0 deletions src/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef struct Unit {
uint8 wobbleIndex; /*!< At which wobble index the Unit currently is. */
int8 spriteOffset; /*!< Offset of the current sprite for Unit. */
uint8 blinkCounter; /*!< If non-zero, it indicates how many more ticks this unit is blinking. */
uint8 blinkHouse; /*!< Indicates for which house the unit is blinking (required for multiplayer). */
uint8 team; /*!< If non-zero, unit is part of team. Value 1 means team 0, etc. */
uint16 timer; /*!< Timer used in animation, to count down when to do the next step. */
uint8 route[14]; /*!< The current route the Unit is following. */
Expand Down

0 comments on commit 63fd5e9

Please sign in to comment.