Skip to content

Commit

Permalink
Gun index logs and assertions (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Oct 30, 2016
1 parent 7533ef4 commit 0470728
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/cdogs/actors.c
Expand Up @@ -572,6 +572,8 @@ void ActorReplaceGun(const NActorReplaceGun rg)
{
return;
}
LOG(LM_ACTOR, LL_DEBUG, "actor uid(%d) replacing gun(%s) idx(%d) size(%d)",
(int)rg.UID, rg.Gun, rg.GunIdx, (int)a->guns.size);
Weapon w = WeaponCreate(gun);
if (a->guns.size <= rg.GunIdx)
{
Expand Down Expand Up @@ -1310,6 +1312,7 @@ void ActorSwitchGun(const NActorSwitchGun sg)
{
TActor *a = ActorGetByUID(sg.UID);
if (a == NULL || !a->isInUse) return;
CASSERT(sg.GunIdx < a->guns.size, "can't switch to unavailable gun");
a->gunIndex = sg.GunIdx;
SoundPlayAt(
&gSoundDevice,
Expand Down
5 changes: 3 additions & 2 deletions src/cdogs/pickup.c
Expand Up @@ -203,8 +203,9 @@ void PickupPickup(TActor *a, Pickup *p, const bool pickupAll)
GameEvent e = GameEventNew(GAME_EVENT_ACTOR_REPLACE_GUN);
e.u.ActorReplaceGun.UID = a->uid;
e.u.ActorReplaceGun.GunIdx =
(int)a->guns.size == MAX_WEAPONS ?
a->gunIndex : (int)a->guns.size;
a->guns.size == MAX_WEAPONS ? a->gunIndex : a->guns.size;
CASSERT(e.u.ActorReplaceGun.GunIdx <= a->guns.size,
"invalid replace gun index");
strcpy(e.u.ActorReplaceGun.Gun, gun->name);
GameEventsEnqueue(&gGameEvents, e);

Expand Down

0 comments on commit 0470728

Please sign in to comment.