player.c: factor out multiple instances of a 3-liner into A_SetHitData().

Playing around with Coccinelle's semantic patches... be prepared for more.

git-svn-id: https://svn.eduke32.com/eduke32@2979 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-09-02 13:58:45 +00:00
parent 8efcc81096
commit 08a19e19f3

View file

@ -314,6 +314,13 @@ static int32_t A_FindTargetSprite(spritetype *s,int32_t aang,int32_t atwith)
return j; return j;
} }
static void A_SetHitData(int32_t i, const hitdata_t *hit)
{
actor[i].t_data[6] = hit->wall;
actor[i].t_data[7] = hit->sect;
actor[i].t_data[8] = hit->sprite;
}
int32_t A_Shoot(int32_t i,int32_t atwith) int32_t A_Shoot(int32_t i,int32_t atwith)
{ {
int16_t l, sa, j, k=-1; int16_t l, sa, j, k=-1;
@ -545,9 +552,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
{ {
k = A_Spawn(j,ProjectileData[atwith].spawns); k = A_Spawn(j,ProjectileData[atwith].spawns);
sprite[k].z -= (8<<8); sprite[k].z -= (8<<8);
actor[k].t_data[6] = hit.wall; A_SetHitData(k, &hit);
actor[k].t_data[7] = hit.sect;
actor[k].t_data[8] = hit.sprite;
} }
if (ProjectileData[atwith].sound >= 0) A_PlaySound(ProjectileData[atwith].sound,j); if (ProjectileData[atwith].sound >= 0) A_PlaySound(ProjectileData[atwith].sound,j);
} }
@ -733,9 +738,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
if (ProjectileData[atwith].extra_rand > 0) if (ProjectileData[atwith].extra_rand > 0)
sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand);
sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1
actor[k].t_data[6] = hit.wall; A_SetHitData(k, &hit);
actor[k].t_data[7] = hit.sect;
actor[k].t_data[8] = hit.sprite;
if (hit.wall == -1 && hit.sprite == -1) if (hit.wall == -1 && hit.sprite == -1)
{ {
@ -755,9 +758,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns); int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns);
if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat;
if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat;
actor[wh].t_data[6] = hit.wall; A_SetHitData(wh, &hit);
actor[wh].t_data[7] = hit.sect;
actor[wh].t_data[8] = hit.sprite;
} }
} }
@ -782,9 +783,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns); int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns);
if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat;
if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat;
actor[wh].t_data[6] = hit.wall; A_SetHitData(wh, &hit);
actor[wh].t_data[7] = hit.sect;
actor[wh].t_data[8] = hit.sprite;
} }
} }
if (p >= 0 && ( if (p >= 0 && (
@ -808,9 +807,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns); int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns);
if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat;
if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat;
actor[wh].t_data[6] = hit.wall; A_SetHitData(wh, &hit);
actor[wh].t_data[7] = hit.sect;
actor[wh].t_data[8] = hit.sprite;
} }
if (CheckDoorTile(wall[hit.wall].picnum) == 1) if (CheckDoorTile(wall[hit.wall].picnum) == 1)
goto DOSKIPBULLETHOLE; goto DOSKIPBULLETHOLE;
@ -905,9 +902,7 @@ DOSKIPBULLETHOLE:
if (ProjectileData[atwith].extra_rand > 0) if (ProjectileData[atwith].extra_rand > 0)
sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand);
sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1
actor[k].t_data[6] = hit.wall; A_SetHitData(k, &hit);
actor[k].t_data[7] = hit.sect;
actor[k].t_data[8] = hit.sprite;
if (hit.sprite >= 0) if (hit.sprite >= 0)
{ {
@ -919,9 +914,7 @@ DOSKIPBULLETHOLE:
int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns); int32_t wh=A_Spawn(k,ProjectileData[atwith].spawns);
if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat;
if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat;
actor[wh].t_data[6] = hit.wall; A_SetHitData(wh, &hit);
actor[wh].t_data[7] = hit.sect;
actor[wh].t_data[8] = hit.sprite;
} }
} }
else sprite[k].xrepeat = sprite[k].yrepeat = 0; else sprite[k].xrepeat = sprite[k].yrepeat = 0;
@ -1147,9 +1140,7 @@ DOSKIPBULLETHOLE:
k = A_Spawn(j,SMALLSMOKE); k = A_Spawn(j,SMALLSMOKE);
sprite[k].z -= (8<<8); sprite[k].z -= (8<<8);
A_PlaySound(KICK_HIT,j); A_PlaySound(KICK_HIT,j);
actor[k].t_data[6] = hit.wall; A_SetHitData(k, &hit);
actor[k].t_data[7] = hit.sect;
actor[k].t_data[8] = hit.sprite;
} }
if (p >= 0 && ps->inv_amount[GET_STEROIDS] > 0 && ps->inv_amount[GET_STEROIDS] < 400) if (p >= 0 && ps->inv_amount[GET_STEROIDS] > 0 && ps->inv_amount[GET_STEROIDS] < 400)
@ -1308,9 +1299,7 @@ DOSKIPBULLETHOLE:
sprite[k].extra = *actorscrptr[atwith]; sprite[k].extra = *actorscrptr[atwith];
sprite[k].extra += (krand()%6); sprite[k].extra += (krand()%6);
sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1
actor[k].t_data[6] = hit.wall; A_SetHitData(k, &hit);
actor[k].t_data[7] = hit.sect;
actor[k].t_data[8] = hit.sprite;
if (hit.wall == -1 && hit.sprite == -1) if (hit.wall == -1 && hit.sprite == -1)
@ -1327,9 +1316,7 @@ DOSKIPBULLETHOLE:
Sect_DamageCeiling(hit.sect); Sect_DamageCeiling(hit.sect);
} }
l = A_Spawn(k,SMALLSMOKE); l = A_Spawn(k,SMALLSMOKE);
actor[l].t_data[6] = hit.wall; A_SetHitData(l, &hit);
actor[l].t_data[7] = hit.sect;
actor[l].t_data[8] = hit.sprite;
} }
if (hit.sprite >= 0) if (hit.sprite >= 0)
@ -1348,9 +1335,7 @@ DOSKIPBULLETHOLE:
else else
{ {
l = A_Spawn(k,SMALLSMOKE); l = A_Spawn(k,SMALLSMOKE);
actor[l].t_data[6] = hit.wall; A_SetHitData(l, &hit);
actor[l].t_data[7] = hit.sect;
actor[l].t_data[8] = hit.sprite;
} }
if (p >= 0 && ( if (p >= 0 && (
@ -1370,9 +1355,7 @@ DOSKIPBULLETHOLE:
else if (hit.wall >= 0) else if (hit.wall >= 0)
{ {
l = A_Spawn(k,SMALLSMOKE); l = A_Spawn(k,SMALLSMOKE);
actor[l].t_data[6] = hit.wall; A_SetHitData(l, &hit);
actor[l].t_data[7] = hit.sect;
actor[l].t_data[8] = hit.sprite;
if (CheckDoorTile(wall[hit.wall].picnum) == 1) if (CheckDoorTile(wall[hit.wall].picnum) == 1)
goto SKIPBULLETHOLE; goto SKIPBULLETHOLE;
@ -1451,9 +1434,7 @@ SKIPBULLETHOLE:
k = A_InsertSprite(hit.sect,hit.pos.x,hit.pos.y,hit.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); k = A_InsertSprite(hit.sect,hit.pos.x,hit.pos.y,hit.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4);
sprite[k].extra = *actorscrptr[atwith]; sprite[k].extra = *actorscrptr[atwith];
sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1
actor[k].t_data[6] = hit.wall; A_SetHitData(k, &hit);
actor[k].t_data[7] = hit.sect;
actor[k].t_data[8] = hit.sprite;
if (hit.sprite >= 0) if (hit.sprite >= 0)
{ {
@ -1461,9 +1442,7 @@ SKIPBULLETHOLE:
if (sprite[hit.sprite].picnum != APLAYER) if (sprite[hit.sprite].picnum != APLAYER)
{ {
l = A_Spawn(k,SMALLSMOKE); l = A_Spawn(k,SMALLSMOKE);
actor[l].t_data[6] = hit.wall; A_SetHitData(l, &hit);
actor[l].t_data[7] = hit.sect;
actor[l].t_data[8] = hit.sprite;
} }
else sprite[k].xrepeat = sprite[k].yrepeat = 0; else sprite[k].xrepeat = sprite[k].yrepeat = 0;
} }