ChangeUnitOwner doesn't need oldplayer argument
This commit is contained in:
parent
bb7602022e
commit
711fc63b0c
4 changed files with 20 additions and 18 deletions
src
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
/**@name action_die.c - The die action. */
|
||||
//
|
||||
// (c) Copyright 1998,2000,2001 by Lutz Sammer
|
||||
// (c) Copyright 1998,2000,2001,2003 by Lutz Sammer
|
||||
//
|
||||
// FreeCraft is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
|
@ -93,7 +93,7 @@ global void HandleActionDie(Unit* unit)
|
|||
UnitShowAnimation(unit,unit->Type->Animations->Die);
|
||||
|
||||
// FIXME: perhaps later or never is better
|
||||
//ChangeUnitOwner(unit,unit->Player,&Players[PlayerNumNeutral]);
|
||||
//ChangeUnitOwner(unit,&Players[PlayerNumNeutral]);
|
||||
}
|
||||
UnitMarkSeen(unit);
|
||||
}
|
||||
|
|
|
@ -773,7 +773,7 @@ extern void UnitIncrementHealth(void);
|
|||
/// Check for rescue each second
|
||||
extern void RescueUnits(void);
|
||||
/// Change owner of unit
|
||||
extern void ChangeUnitOwner(Unit* unit,Player* old,Player* new);
|
||||
extern void ChangeUnitOwner(Unit* unit,Player* newplayer);
|
||||
|
||||
/// Convert direction (dx,dy) to heading (0-255)
|
||||
extern int DirectionToHeading(int,int);
|
||||
|
|
|
@ -286,24 +286,27 @@ local SCM CclPlayer(SCM list)
|
|||
}
|
||||
|
||||
/**
|
||||
** Change Unit Owner
|
||||
** Change unit owner
|
||||
**
|
||||
** @param pos1 top left tile
|
||||
** @param pos2 bottom right tile
|
||||
** @param old old player number
|
||||
** @param new new player number
|
||||
**/
|
||||
local SCM CclChangeUnitsOwner(SCM pos1, SCM pos2, SCM old, SCM new)
|
||||
local SCM CclChangeUnitsOwner(SCM pos1, SCM pos2, SCM oldplayer, SCM newplayer)
|
||||
{
|
||||
Unit* table[UnitMax];
|
||||
int n;
|
||||
int oldp;
|
||||
int newp;
|
||||
|
||||
n = SelectUnits(gh_scm2int(gh_car(pos1)), gh_scm2int(gh_cadr(pos1)),
|
||||
gh_scm2int(gh_car(pos2)), gh_scm2int(gh_cadr(pos2)), table);
|
||||
n=SelectUnits(gh_scm2int(gh_car(pos1)), gh_scm2int(gh_cadr(pos1)),
|
||||
gh_scm2int(gh_car(pos2)), gh_scm2int(gh_cadr(pos2)), table);
|
||||
oldp=gh_scm2int(oldplayer);
|
||||
newp=gh_scm2int(newplayer);
|
||||
while( n ) {
|
||||
if(table[n-1]->Player->Player == gh_scm2int(old)) {
|
||||
ChangeUnitOwner(table[n-1],&Players[gh_scm2int(old)],
|
||||
&Players[gh_scm2int(new)]);
|
||||
if( table[n-1]->Player->Player == oldp ) {
|
||||
ChangeUnitOwner(table[n-1],&Players[newp]);
|
||||
}
|
||||
n--;
|
||||
}
|
||||
|
|
|
@ -1708,25 +1708,24 @@ global void UnitIncrementHealth(void)
|
|||
** Change the unit's owner
|
||||
**
|
||||
** @param unit Unit which should be consigned.
|
||||
** @param oldplayer Old owning player.
|
||||
** @param newplayer New owning player.
|
||||
**
|
||||
** @todo FIXME: I think here are some failures, if building is build
|
||||
** what is with the unit inside? or a main hall with workers
|
||||
** inside?
|
||||
** Parameter old player is redunant?
|
||||
*/
|
||||
global void ChangeUnitOwner(Unit* unit,Player* oldplayer,Player* newplayer)
|
||||
global void ChangeUnitOwner(Unit* unit,Player* newplayer)
|
||||
{
|
||||
int i;
|
||||
Player* oldplayer;
|
||||
|
||||
DebugCheck( unit->Player!=oldplayer );
|
||||
oldplayer=unit->Player;
|
||||
|
||||
// For st*rcr*ft (dark archons),
|
||||
if( unit->Type->Transporter ) {
|
||||
for( i=0; i<MAX_UNITS_ONBOARD; i++) {
|
||||
if( unit->OnBoard[i] ) {
|
||||
ChangeUnitOwner(unit->OnBoard[i],oldplayer,newplayer);
|
||||
ChangeUnitOwner(unit->OnBoard[i],newplayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1811,7 +1810,7 @@ local void ChangePlayerOwner(Player* oldplayer,Player* newplayer)
|
|||
memcpy(table,oldplayer->Units,n*sizeof(Unit*));
|
||||
for( i=0; i<n; i++ ) {
|
||||
unit=table[i];
|
||||
ChangeUnitOwner(unit,oldplayer,newplayer);
|
||||
ChangeUnitOwner(unit,newplayer);
|
||||
unit->Blink=5;
|
||||
unit->Rescued=1;
|
||||
}
|
||||
|
@ -1882,7 +1881,7 @@ global void RescueUnits(void)
|
|||
#endif
|
||||
if( around[i]->Type->CanAttack &&
|
||||
IsAllied(unit->Player,around[i]) ) {
|
||||
ChangeUnitOwner(unit,unit->Player,around[i]->Player);
|
||||
ChangeUnitOwner(unit,around[i]->Player);
|
||||
unit->Blink=5;
|
||||
unit->Rescued=1;
|
||||
PlayGameSound(GameSounds.Rescue[unit->Player->Race].Sound
|
||||
|
@ -3661,7 +3660,7 @@ global void HitUnit(Unit* attacker,Unit* target,int damage)
|
|||
&& IsEnemy(attacker->Player,target)
|
||||
&& (attacker->Type==UnitTypeOrcWorker
|
||||
|| attacker->Type==UnitTypeHumanWorker) ) {
|
||||
ChangeUnitOwner(target, target->Player, attacker->Player);
|
||||
ChangeUnitOwner(target,attacker->Player);
|
||||
CommandStopUnit(attacker); // Attacker shouldn't continue attack!
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue