Each player can only control one Clonk simultaneously

Switching between multiple Clonks is still supported, and
Script could issue Follow commands to simulate the old
behaviour.
stable-5.1
Günther Brammer 2010-07-30 22:38:21 +02:00
parent 51e064398a
commit fbdc799ae5
18 changed files with 14534 additions and 5677 deletions

19615
docs/en.po

File diff suppressed because it is too large Load Diff

View File

@ -11,18 +11,17 @@
<rtype>object</rtype>
<params>
<param><type>int</type><name>player</name><desc>Spielernummer des Spielers, dessen kontrollierter Clonk zurückgegeben werden soll.</desc></param>
<param><type>int</type><name>index</name><desc>Index, mit dem durch die ausgewählte Crew durchgeschaltet werden kann. 0 gibt immer den aktiv gelenkten Clonk zurück.</desc><optional /></param>
</params>
</syntax>
<desc>Gibt den momentan kontrollierten Clonk eines Spielers zurück. Werden mehrere Clonks gelenkt, ist es bei index=0 (oder weggelassen) immer das primär ausgewählte Mannschaftsmitglied. Also das, dem beispielsweise auch die Sicht folgt.</desc>
<desc>Gibt den momentan kontrollierten Clonk eines Spielers zurück.</desc>
<examples>
<example>
<code><funclink>if</funclink> (!GetCursor(0)) <funclink>SetCursor</funclink>(<funclink>GetHiRank</funclink>(0));</code>
<text>Wählt den höchstrangigen Clonk des ersten Spielers aus, wenn ansonsten gerade kein anderer Clonk ausgewählt ist.</text>
</example>
<example>
<code>var crew,i; <funclink>while</funclink> (crew=GetCursor(0,i++)) crew-><funclink>Message</funclink>("Hurra!");</code>
<text>Gibt eine Nachricht über allen ausgewählten Clonks des ersten Spielers aus.</text>
<code>GetCursor(0)-><funclink>Message</funclink>("Hurra!");</code>
<text>Gibt eine Nachricht über dem ausgewählten Clonk des ersten Spielers aus.</text>
</example>
</examples>
<related>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE funcs SYSTEM "../../../clonk.dtd">
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>GetSelectCount</title>
<category>Spieler</category>
<version>4.6.5.0 CP</version>
<syntax>
<rtype>int</rtype>
<params>
<param><type>int</type><name>player</name><desc>Spieler-Nummer.</desc></param>
</params>
</syntax>
<desc>Liefert die Anzahl der ausgewählten Clonks von Spieler player.</desc>
<related>
<funclink>SelectCrew</funclink>
</related>
</func>
<author>Cucaracha</author><date>Mai 2002</date>
</funcs>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE funcs SYSTEM "../../../clonk.dtd">
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>SelectCrew</title>
<category>Spieler</category>
<version>4.6.5.0 CP</version>
<syntax>
<rtype>bool</rtype>
<params>
<param><type>int</type><name>player</name><desc>Spielernummer.</desc></param>
<param><type>object</type><name>obj</name><desc>An- bzw. abzuwählendes Objekt</desc></param>
<param><type>bool</type><name>do_select</name><desc>Auswahl, ob an- oder abgewählt werden soll.</desc></param>
</params>
</syntax>
<desc>Aktiviert bzw. deaktiviert ein Mannschaftsmitglied für die Steuerung.</desc>
<remark>Es bleibt jedoch immer mindestens ein Objekt für die Steuerung markiert und aktiviert.</remark>
<related>
<funclink>SetCursor</funclink>
</related>
</func>
<author>jwk</author><date>August 2002</date>
</funcs>

View File

@ -11,7 +11,6 @@
<params>
<param><type>int</type><name>player</name><desc>Spielernummer</desc></param>
<param><type>object</type><name>obj</name><desc>Anzuwählendes Objekt</desc></param>
<param><type>bool</type><name>no_select_mark</name><desc>Wenn ungleich 0, wird bei der Anwahl kein Auswahlrahmen angezeigt. Ab CE.</desc><optional /></param>
<param><type>bool</type><name>no_select_arrow</name><desc>Wenn ungleich 0, wird bei der Anwahl kein Auswahlpfeil angezeigt. Ab CE.</desc><optional /></param>
</params>
</syntax>

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE funcs SYSTEM "../../../clonk.dtd">
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>UnselectCrew</title>
<category>Objekte</category>
<subcat>Mannschaft</subcat>
<version>4.9.1.0 GWE</version>
<syntax>
<rtype>bool</rtype>
<params>
<param><type>int</type><name>player</name><desc>Spieler, dessen Mannschaft abgewählt werden soll.</desc></param>
</params>
</syntax>
<desc>Wählt die gesamte Mannschaft eines Spieler ab. Nach dem Aufruf dieses Befehls sollte mit <funclink>SelectCrew</funclink> wieder ein Clonk angewählt werden.</desc>
<examples>
<example>
<code>UnselectCrew();
SelectCrew(0, GetHiRank(), 1);</code>
<text>Wählt nur den höchstrangigen Clonk des ersten Spielers an. Siehe dazu auch <funclink>SetCursor</funclink>.</text>
</example>
</examples>
<related>
<funclink>SelectCrew</funclink>
<funclink>SetCursor</funclink>
<funclink>GetCrewEnabled</funclink>
<funclink>SetCrewEnabled</funclink>
</related>
</func>
<author>Sven2</author><date>April 2002</date>
</funcs>

View File

@ -1641,7 +1641,7 @@ void C4Game::DrawCursors(C4TargetFacet &cgo, int32_t iPlayer)
C4Facet &fctCursor = GraphicsResource.fctCursor;
for (C4Player *pPlr=Players.First; pPlr; pPlr=pPlr->Next)
if (pPlr->Number == iPlayer || iPlayer==NO_OWNER)
if (pPlr->CursorFlash || pPlr->SelectFlash)
if (pPlr->CursorFlash)
if (pPlr->Cursor)
{
cursor=pPlr->Cursor;

View File

@ -147,19 +147,6 @@ const BYTE CNAT_Flags = CNAT_MultiAttach | CNAT_NoCollision; // all attchment fl
const int C4DoubleClick = 10;
const int CON_CursorLeft = 0,
CON_CursorToggle = 1,
CON_CursorRight = 2,
CON_Throw = 3,
CON_Up = 4,
CON_Dig = 5,
CON_Left = 6,
CON_Down = 7,
CON_Right = 8,
CON_Menu = 9,
CON_Special = 10,
CON_Special2 = 11;
//=================================== Control Commands ======================================================
const BYTE COM_Single = 64,
@ -212,10 +199,7 @@ const BYTE COM_Left = 1,
COM_Special2_D = COM_Special2 | COM_Double;
const BYTE COM_CursorLeft = 30,
COM_CursorRight = 31,
COM_CursorToggle = 32;
const BYTE COM_CursorToggle_D = COM_CursorToggle | COM_Double;
COM_CursorRight = 31;
const BYTE COM_Help = 35,
COM_PlayerMenu = 36,

View File

@ -351,7 +351,6 @@ void C4ControlPlayerSelect::Execute() const
// Check object list
C4Object *pObj;
C4ObjectList SelectObjs;
int32_t iControlChecksum = 0;
for (int32_t i = 0; i < iObjCnt; i++)
if ((pObj = ::Objects.SafeObjectPointer(pObjNrs[i])))
@ -365,16 +364,9 @@ void C4ControlPlayerSelect::Execute() const
else
pObj->Call(PSF_MouseSelection, &C4AulParSet(C4VInt(iPlr)));
}
// player crew selection (recheck status of pObj)
if (pObj->Status && pPlr->ObjectInCrew(pObj) && !fIsAlt)
SelectObjs.Add(pObj, C4ObjectList::stNone);
}
// count
pPlr->CountControl(C4Player::PCID_Command, iControlChecksum);
// any crew to be selected (or complete crew deselection)?
if (!fIsAlt) if (!SelectObjs.IsClear() || !iObjCnt)
pPlr->SelectCrew(SelectObjs);
}
void C4ControlPlayerSelect::CompileFunc(StdCompiler *pComp)

View File

@ -479,12 +479,6 @@ void C4Command::Dig()
void C4Command::Follow()
{
// If crew member, only selected objects can follow
if (cObj->Def->CrewMember)
// Finish successfully to avoid fail message
if (!cObj->Select && cObj->Owner != NO_OWNER) { Finish(true); return; }
// No-one to follow
if (!Target) { Finish(); return; }

View File

@ -183,7 +183,6 @@ void C4Object::Default()
fix_x=fix_y=fix_r=0;
xdir=ydir=rdir=0;
Mobile=0;
Select=0;
Unsorted=false;
Initializing=false;
OnFire=0;
@ -1255,7 +1254,6 @@ void C4Object::AssignDeath(bool fForced)
// Action
SetActionByName("Dead");
// Values
Select=0;
Alive=0;
ClearCommands();
if (Info)
@ -2496,14 +2494,6 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
// local particles in front of the object
if (FrontParticles) if (eDrawMode!=ODM_BaseOnly) FrontParticles.Draw(cgo,this);
// Select Mark
if (Select)
if (eDrawMode!=ODM_BaseOnly)
if (ValidPlr(Owner))
if (Owner == iByPlayer)
if (::Players.Get(Owner)->SelectFlash)
DrawSelectMark(cgo, 1);
// Energy shortage
if (NeedEnergy) if (::Game.iTick35>12) if (eDrawMode!=ODM_BaseOnly)
{
@ -2758,7 +2748,6 @@ void C4Object::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt( SolidMask, "SolidMask", Def->SolidMask ));
pComp->Value(mkNamingAdapt( PictureRect, "Picture" ));
pComp->Value(mkNamingAdapt( Mobile, "Mobile", false ));
pComp->Value(mkNamingAdapt( Select, "Selected", false ));
pComp->Value(mkNamingAdapt( OnFire, "OnFire", false ));
pComp->Value(mkNamingAdapt( InLiquid, "InLiquid", false ));
pComp->Value(mkNamingAdapt( EntranceStatus, "EntranceStatus", false ));
@ -5106,28 +5095,20 @@ void C4Object::ApplyParallaxity(float &riTx, float &riTy, const C4Facet &fctView
riTy = riTy * iParY / 100;
}
bool C4Object::DoSelect(bool fCursor)
bool C4Object::DoSelect()
{
// selection allowed?
if (CrewDisabled) return true;
// was already selected
if (Select) return true;
// select
if (!fCursor) Select=1;
if (CrewDisabled) return false;
// do callback
Call(PSF_CrewSelection, &C4AulParSet(C4VBool(false), C4VBool(!!fCursor)));
Call(PSF_CrewSelection, &C4AulParSet(C4VBool(false)));
// done
return true;
}
void C4Object::UnSelect(bool fCursor)
void C4Object::UnSelect()
{
// was not selected
if (!Select) return;
// unselect
if (!fCursor) Select=0;
// do callback
Call(PSF_CrewSelection, &C4AulParSet(C4VBool(true), C4VBool(!!fCursor)));
Call(PSF_CrewSelection, &C4AulParSet(C4VBool(true)));
}
void C4Object::GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport)

View File

@ -159,7 +159,6 @@ public:
C4Real xdir,ydir,rdir;
int32_t iLastAttachMovementFrame; // last frame in which Attach-movement by a SolidMask was done
bool Mobile;
bool Select;
bool Unsorted; // NoSave //
bool Initializing; // NoSave //
bool InLiquid;
@ -380,8 +379,8 @@ public:
{ SideBounds(ctcox); VerticalBounds(ctcoy); }
public:
bool DoSelect(bool fCursor=false); // select in crew (or just set cursor) if not disabled
void UnSelect(bool fCursor=false); // unselect in crew (or just task away cursor)
bool DoSelect(); // cursor callback if not disabled
void UnSelect(); // unselect callback
void GetViewPos(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) // get position this object is seen at (for given scroll)
{ if (Category & C4D_Parallax) GetViewPosPar(riX, riY, tx, ty, fctViewport); else { riX=float(GetX()); riY=float(GetY()); } }
void GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport); // get position this object is seen at, calculating parallaxity

View File

@ -857,55 +857,6 @@ const char *ComName(int32_t iCom)
return "Undefined";
}
int32_t Com2Control(int32_t iCom)
{
iCom = iCom & ~(COM_Double | COM_Single);
switch (iCom)
{
case COM_CursorLeft: return CON_CursorLeft;
case COM_CursorToggle: return CON_CursorToggle;
case COM_CursorRight: return CON_CursorRight;
case COM_Throw: return CON_Throw;
case COM_Up: return CON_Up;
case COM_Dig: return CON_Dig;
case COM_Left: return CON_Left;
case COM_Down: return CON_Down;
case COM_Right: return CON_Right;
case COM_Special: return CON_Special;
case COM_Special2: return CON_Special2;
}
return CON_Menu;
}
int32_t Control2Com(int32_t iControl, bool fUp)
{
static const char con2com[C4MaxKey]=
{
COM_CursorLeft, COM_CursorToggle, COM_CursorRight,
COM_Throw, COM_Up, COM_Dig,
COM_Left, COM_Down, COM_Right,
COM_PlayerMenu, COM_Special, COM_Special2
};
static const char con2com_r[C4MaxKey]=
{
COM_None, COM_None, COM_None,
COM_Throw_R, COM_Up_R, COM_Dig_R,
COM_Left_R, COM_Down_R, COM_Right_R,
COM_None, COM_Special_R, COM_Special2_R
};
if (fUp)
{
if (Inside<int32_t>(iControl,0,C4MaxKey-1))
return con2com_r[iControl];
}
else
{
if (Inside<int32_t>(iControl,0,C4MaxKey-1))
return con2com[iControl];
}
return COM_None;
}
int32_t Coms2ComDir(int32_t iComs)
{
// This is possible because COM_Left - COM_Down are < 32

View File

@ -28,13 +28,10 @@
class C4Facet;
class C4Object;
int32_t Control2Com(int32_t iControl, bool fUp);
int32_t Com2Control(int32_t iCom);
int32_t Coms2ComDir(int32_t iComs);
bool ComDirLike(int32_t iComDir, int32_t iSample);
const char *ComName(int32_t iCom);
int32_t ComOrder(int32_t iCom);
StdStrBuf PlrControlKeyName(int32_t iPlayer, int32_t iControl, bool fShort);
const int32_t ComOrderNum = 24;

View File

@ -223,7 +223,6 @@ void C4Player::Execute()
if (ViewWealth>0) ViewWealth--;
if (ViewScore>0) ViewScore--;
if (CursorFlash>0) CursorFlash--;
if (SelectFlash>0) SelectFlash--;
}
bool C4Player::Init(int32_t iNumber, int32_t iAtClient, const char *szAtClientName,
@ -892,51 +891,49 @@ bool C4Player::IsHostileTowards(const C4Player *plr) const
return Hostility.find(plr) != Hostility.end();
}
C4Object* C4Player::GetHiExpActiveCrew(bool fSelectOnly)
C4Object* C4Player::GetHiExpActiveCrew()
{
C4ObjectLink *clnk;
C4Object *cobj,*hiexp=NULL;
int32_t iHighestExp=-2, iExp;
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
if (!cobj->CrewDisabled)
if (!fSelectOnly || cobj->Select)
{
if (cobj->Info) iExp = cobj->Info->Experience; else iExp=-1;
if (!hiexp || (iExp>iHighestExp))
{
if (cobj->Info) iExp = cobj->Info->Experience; else iExp=-1;
if (!hiexp || (iExp>iHighestExp))
{
hiexp=cobj;
iHighestExp=iExp;
}
hiexp=cobj;
iHighestExp=iExp;
}
}
return hiexp;
}
C4Object* C4Player::GetHiRankActiveCrew(bool fSelectOnly)
C4Object* C4Player::GetHiRankActiveCrew()
{
C4ObjectLink *clnk;
C4Object *cobj,*hirank=NULL;
int32_t iHighestRank=-2, iRank;
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
if (!cobj->CrewDisabled)
if (!fSelectOnly || cobj->Select)
{
if (cobj->Info) iRank = cobj->Info->Rank; else iRank=-1;
if (!hirank || (iRank>iHighestRank))
{
if (cobj->Info) iRank = cobj->Info->Rank; else iRank=-1;
if (!hirank || (iRank>iHighestRank))
{
hirank=cobj;
iHighestRank=iRank;
}
hirank=cobj;
iHighestRank=iRank;
}
}
return hirank;
}
void C4Player::CheckCrewExPromotion()
{
C4Object *hirank;
if ((hirank=GetHiRankActiveCrew(false)))
if ((hirank=GetHiRankActiveCrew()))
if (hirank->Info)
if (hirank->Info->Rank<1) // No Fähnrich -> except. promo.
if ((hirank=GetHiExpActiveCrew(false)))
if ((hirank=GetHiExpActiveCrew()))
hirank->Promote(1,true,false);
}
@ -1134,26 +1131,17 @@ void C4Player::AdjustCursorCommand()
{
// Reset view
ResetCursorView();
// Set cursor to hirank Select clonk
C4Object *pHiRank=NULL;
// Find hirank Select
pHiRank = GetHiRankActiveCrew(true);
// If none, check non-Selects as well
if (!pHiRank)
pHiRank = GetHiRankActiveCrew(false);
// The cursor is on someone else: set the cursor to the hirank
C4Object* pPrev = Cursor;
if (Cursor != pHiRank)
// Default cursor to hirank clonk
if (!Cursor || Cursor->CrewDisabled)
{
Cursor=pHiRank;
C4Object *pHiRank = GetHiRankActiveCrew();
if (!pHiRank)
return;
Cursor = pHiRank;
UpdateView();
Cursor->DoSelect();
CursorFlash=30;
}
// UnSelect previous cursor
if (pPrev && pPrev != Cursor) pPrev->UnSelect(true);
// We have a cursor: do select it
if (Cursor) { /*Cursor->DoSelect(true);*/ Cursor->DoSelect(); } // Hmm, why DoSelect() twice? I hope the second one is the correct one...
// Updates
CursorFlash=30;
}
void C4Player::CursorRight()
@ -1166,10 +1154,9 @@ void C4Player::CursorRight()
if (!cLnk)
for (cLnk=Crew.First; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status && !cLnk->Obj->CrewDisabled) break;
if (cLnk) SetCursor(cLnk->Obj, false, true);
if (cLnk) SetCursor(cLnk->Obj, true);
// Updates
CursorFlash=30;
CursorSelection=1;
UpdateView();
}
@ -1183,148 +1170,21 @@ void C4Player::CursorLeft()
if (!cLnk)
for (cLnk=Crew.Last; cLnk; cLnk=cLnk->Prev)
if (cLnk->Obj->Status && !cLnk->Obj->CrewDisabled) break;
if (cLnk) SetCursor(cLnk->Obj, false, true);
if (cLnk) SetCursor(cLnk->Obj, true);
// Updates
CursorFlash=30;
CursorSelection=1;
UpdateView();
}
void C4Player::UnselectCrew()
{
C4Object *cObj; C4ObjectLink *cLnk; bool fCursorDeselected = false;
for (cLnk=Crew.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
{
if (Cursor == cObj) fCursorDeselected = true;
if (cObj->Status)
cObj->UnSelect();
}
// if cursor is outside crew (done by some scenarios), unselect that one, too! (script callback)
if (Cursor && !fCursorDeselected) Cursor->UnSelect();
}
void C4Player::SelectSingleByCursor()
{
// Unselect crew
UnselectCrew();
// Select cursor
if (Cursor) Cursor->DoSelect();
// Updates
SelectFlash=30;
AdjustCursorCommand();
}
void C4Player::SelectSingle(C4Object *tobj)
{
// clear previous cursor
if (Cursor) Cursor->UnSelect(true);
// Set cursor
Cursor=tobj;
if (Cursor) Cursor->DoSelect(true);
// Now use PlayerSelectSingleByCursor
SelectSingleByCursor();
}
void C4Player::CursorToggle()
{
C4ObjectLink *clnk;
// Selection mode: toggle cursor select
if (CursorSelection)
{
if (Cursor)
{
if (Cursor->Select) Cursor->UnSelect();
else Cursor->DoSelect();
}
CursorToggled=1;
}
// Pure toggle: toggle all Select
else
{
for (clnk=Crew.First; clnk; clnk=clnk->Next)
if (!clnk->Obj->CrewDisabled)
{
if (clnk->Obj->Select) clnk->Obj->UnSelect();
else clnk->Obj->DoSelect();
}
AdjustCursorCommand();
}
// Updates
SelectFlash=30;
}
void C4Player::SelectAllCrew()
{
C4ObjectLink *clnk;
// Select all crew
for (clnk=Crew.First; clnk; clnk=clnk->Next)
clnk->Obj->DoSelect();
// Updates
AdjustCursorCommand();
CursorSelection=CursorToggled=0;
SelectFlash=30;
// Game display
if (LocalControl) StartSoundEffect("Ding");
}
void C4Player::UpdateSelectionToggleStatus()
{
if (CursorSelection)
{
// Select toggled: cursor to hirank
if (CursorToggled)
AdjustCursorCommand();
// Cursor select only: single control
else
SelectSingleByCursor();
}
CursorSelection=0;
CursorToggled=0;
}
bool C4Player::ObjectCommand(int32_t iCommand, C4Object *pTarget, int32_t iX, int32_t iY, C4Object *pTarget2, C4Value iData, int32_t iMode)
{
// Eliminated
if (Eliminated) return false;
// Hide startup
if (ShowStartup) ShowStartup=false;
// Update selection & toggle status
UpdateSelectionToggleStatus();
// Apply to all selected crew members (in cursor range) except pTarget.
// Set, Add, Append mode flags may be combined and have a priority order.
C4ObjectLink *cLnk; C4Object *cObj; bool fCursorProcessed = false;
for (cLnk=Crew.First; cLnk && (cObj=cLnk->Obj); cLnk=cLnk->Next)
{
if (cObj == Cursor) fCursorProcessed = true;
if (cObj->Status) if (cObj->Select)
if ( !(iMode & C4P_Command_Range) || (Cursor && Inside<int32_t>(cObj->GetX()-Cursor->GetX(),-15,+15) && Inside<int32_t>(cObj->GetY()-Cursor->GetY(),-15,+15)) )
if (cObj!=pTarget)
{
// Put command with unspecified put object
if ((iCommand == C4CMD_Put) && !pTarget2)
{
// Special: the put command is only applied by this function if the clonk actually
// has something to put. Also, the put count is adjusted to that the clonk will not try to put
// more items than he actually has. This workaround is needed so the put command can be used
// to tell all selected clonks to put when in a container, simulating the old all-throw behavior.
if (cObj->Contents.ObjectCount(iData.getC4ID()))
ObjectCommand2Obj(cObj, iCommand, pTarget, Min<int32_t>(iX, cObj->Contents.ObjectCount(iData.getC4ID())), iY, pTarget2, iData, iMode);
}
// Other command
else
ObjectCommand2Obj(cObj, iCommand, pTarget, iX, iY, pTarget2, iData, iMode);
// don't issue multiple Construct-commands - store previous Clonk as target for next command object
// note that if three Clonks get the command, and the middle one gets deleted (the Clonk, not the command), the third will start to build anyway
// that is very unlikely, though...could be catched in ClearPointers, if need be?
// also, if one Clonk of the chain aborts his command (controlled elsewhere, for instance), the following ones will fail their commands
// It's not a perfect solution, after all. But certainly better than placing tons of construction sites in the first place
if (iCommand == C4CMD_Construct) pTarget = cObj;
}
}
// Always apply to cursor, even if it's not in the crew
if (Cursor && !fCursorProcessed)
if (Cursor->Status && Cursor != pTarget)
ObjectCommand2Obj(Cursor, iCommand, pTarget, iX, iY, pTarget2, iData, iMode);
if (Cursor && Cursor->Status && Cursor != pTarget)
ObjectCommand2Obj(Cursor, iCommand, pTarget, iX, iY, pTarget2, iData, iMode);
// Success
return true;
@ -1369,13 +1229,9 @@ void C4Player::CompileFunc(StdCompiler *pComp, bool fExact)
pComp->Value(mkNamingAdapt(Hostility, "Hostile" ));
pComp->Value(mkNamingAdapt(ProductionDelay, "ProductionDelay", 0));
pComp->Value(mkNamingAdapt(ProductionUnit, "ProductionUnit", 0));
pComp->Value(mkNamingAdapt(SelectCount, "SelectCount", 0));
pComp->Value(mkNamingAdapt(SelectFlash, "SelectFlash", 0));
pComp->Value(mkNamingAdapt(CursorFlash, "CursorFlash", 0));
pComp->Value(mkNamingAdapt(Cursor, "Cursor", C4ObjectPtr::Null));
pComp->Value(mkNamingAdapt(ViewCursor, "ViewCursor", C4ObjectPtr::Null));
pComp->Value(mkNamingAdapt(CursorSelection, "CursorSelection", 0));
pComp->Value(mkNamingAdapt(CursorToggled, "CursorToggled", 0));
pComp->Value(mkNamingAdapt(MessageStatus, "MessageStatus", 0));
pComp->Value(mkNamingAdapt(toC4CStr(MessageBuf),"MessageBuf", ""));
pComp->Value(mkNamingAdapt(HomeBaseMaterial, "HomeBaseMaterial" ));
@ -1428,13 +1284,12 @@ void C4Player::ExecHomeBaseProduction()
void C4Player::UpdateCounts()
{
int32_t nclkcnt,nselcnt;
C4Object *cobj; C4ObjectLink *clnk;
nclkcnt=nselcnt=0;
CrewCnt = 0;
for (clnk=Crew.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
{ nclkcnt++; if (cobj->Select) nselcnt++; }
if (CrewCnt!=nclkcnt) CrewCnt=nclkcnt;
if (SelectCount!=nselcnt) SelectCount=nselcnt;
{
++CrewCnt;
}
}
void C4Player::CheckElimination()
@ -1492,7 +1347,6 @@ void C4Player::DefaultRuntimeData()
ViewMode=C4PVM_Cursor;
ViewX=ViewY=0;
ViewTarget=NULL;
CursorSelection=CursorToggled=0;
ShowStartup=true;
CrewCnt=0;
ViewWealth=ViewScore=0;
@ -1501,9 +1355,7 @@ void C4Player::DefaultRuntimeData()
ObjectsOwned=0;
ProductionDelay=ProductionUnit=0;
Cursor=ViewCursor=NULL;
SelectCount=0;
SelectFlash=CursorFlash=30;
CursorSelection=CursorToggled=0;
CursorFlash=30;
MessageStatus=0;
MessageBuf[0]=0;
Hostility.clear();
@ -1590,7 +1442,7 @@ bool C4Player::DoScore(int32_t iChange)
return true;
}
void C4Player::SetCursor(C4Object *pObj, bool fSelectFlash, bool fSelectArrow)
void C4Player::SetCursor(C4Object *pObj, bool fSelectArrow)
{
// check disabled
if (pObj) if (pObj->CrewDisabled) return;
@ -1599,27 +1451,11 @@ void C4Player::SetCursor(C4Object *pObj, bool fSelectFlash, bool fSelectArrow)
// Set cursor
Cursor=pObj;
// unselect previous
if (pPrev && fChanged) pPrev->UnSelect(true);
if (pPrev && fChanged) pPrev->UnSelect();
// Select object
if (Cursor) { Cursor->DoSelect(true); /*Cursor->DoSelect();*/ } // Sven2: why the second DoSelect()? - it breaks cursor-toggle-selection
if (Cursor) { Cursor->DoSelect(); }
// View flash
if (fSelectArrow) CursorFlash=30;
if (fSelectFlash) SelectFlash=30;
}
void C4Player::SelectCrew(C4ObjectList &rList)
{
// Unselect
UnselectCrew();
// Select (does not check whether objects are in crew)
C4ObjectLink *clnk;
for (clnk=rList.First; clnk; clnk=clnk->Next)
if (clnk->Obj->Status)
clnk->Obj->DoSelect();
// Updates
AdjustCursorCommand();
CursorSelection=CursorToggled=0;
SelectFlash=30;
}
void C4Player::ScrollView(int32_t iX, int32_t iY, int32_t ViewWdt, int32_t ViewHgt)
@ -1793,19 +1629,6 @@ bool C4Player::FoWIsVisible(int32_t x, int32_t y)
return fSeen;
}
void C4Player::SelectCrew(C4Object *pObj, bool fSelect)
{
// Not a valid crew member
if (!pObj || !Crew.GetLink(pObj)) return;
// Select/unselect
if (fSelect) pObj->DoSelect();
else pObj->UnSelect();
// Updates
SelectFlash=30;
CursorSelection=CursorToggled=0;
AdjustCursorCommand();
}
void C4Player::CloseMenu()
{
// cancel all player menus
@ -1851,15 +1674,9 @@ int32_t C4Player::ActiveCrewCount()
int32_t C4Player::GetSelectedCrewCount()
{
int32_t iNum=0;
C4Object *cObj;
for (C4ObjectLink *cLnk=Crew.First; cLnk; cLnk=cLnk->Next)
if ((cObj=cLnk->Obj))
if (!cObj->CrewDisabled)
if (cObj->Select)
++iNum;
// return it
return iNum;
if (Cursor && !Cursor->CrewDisabled)
return 1;
return 0;
}
void C4Player::EvaluateLeague(bool fDisconnected, bool fWon)

View File

@ -126,9 +126,7 @@ public:
// Control
C4PlayerControl Control;
C4ObjectPtr Cursor, ViewCursor;
int32_t SelectCount;
int32_t SelectFlash,CursorFlash;
int32_t CursorSelection,CursorToggled;
int32_t CursorFlash;
class C4GamePadOpener *pGamepad;
// Message
int32_t MessageStatus;
@ -151,7 +149,6 @@ public:
public:
void Eliminate();
void SelectCrew(C4Object *pObj, bool fSelect);
void Default();
void Clear();
void ClearPointers(C4Object *tptr, bool fDeath);
@ -162,8 +159,7 @@ public:
void Evaluate();
void Surrender();
void ScrollView(int32_t iX, int32_t iY, int32_t ViewWdt, int32_t ViewHgt);
void SelectCrew(C4ObjectList &rList);
void SetCursor(C4Object *pObj, bool fSelectFlash, bool fSelectArrow);
void SetCursor(C4Object *pObj, bool fSelectArrow);
void RemoveCrewObjects();
void NotifyOwnedObjects();
void DefaultRuntimeData();
@ -171,12 +167,6 @@ public:
void AdjustCursorCommand();
void CursorRight();
void CursorLeft();
void UnselectCrew();
void SelectSingleByCursor();
void SelectSingle(C4Object *tobj);
void CursorToggle();
void SelectAllCrew();
void UpdateSelectionToggleStatus();
bool ObjectCommand(int32_t iCommand, C4Object *pTarget, int32_t iTx, int32_t iTy, C4Object *pTarget2=NULL, C4Value iData=C4VNull, int32_t iAddMode=C4P_Command_Set);
void ObjectCommand2Obj(C4Object *cObj, int32_t iCommand, C4Object *pTarget, int32_t iX, int32_t iY, C4Object *pTarget2, C4Value iData, int32_t iMode);
@ -203,8 +193,8 @@ public:
bool ActivateMenuMain();
bool ActivateMenuTeamSelection(bool fFromMain);
void DoTeamSelection(int32_t idTeam);
C4Object *GetHiExpActiveCrew(bool fSelectedOnly);
C4Object *GetHiRankActiveCrew(bool fSelectedOnly);
C4Object *GetHiExpActiveCrew();
C4Object *GetHiRankActiveCrew();
void SetFoW(bool fEnable);
int32_t ActiveCrewCount();
int32_t GetSelectedCrewCount();

View File

@ -2410,11 +2410,6 @@ static bool FnSetPlrView(C4AulContext *cthr, long iPlr, C4Object *tobj)
return true;
}
static C4String *FnGetPlrControlName(C4AulContext *cthr, long iPlr, long iCon, bool fShort)
{
return String(PlrControlKeyName(iPlr,iCon,fShort).getData());
}
static long FnGetPlrViewMode(C4AulContext *cthr, long iPlr)
{
if (!ValidPlr(iPlr)) return -1;
@ -2626,7 +2621,7 @@ static long FnGetPlayerScoreGain(C4AulContext *cthr, long iPlr)
static C4Object *FnGetHiRank(C4AulContext *cthr, long iPlr)
{
if (!ValidPlr(iPlr)) return false;
return ::Players.Get(iPlr)->GetHiRankActiveCrew(false);
return ::Players.Get(iPlr)->GetHiRankActiveCrew();
}
static C4Object *FnGetCrew(C4AulContext *cthr, long iPlr, long index)
@ -2722,30 +2717,13 @@ static bool FnCreateScriptPlayer(C4AulContext *cthr, C4String *szName, long dwCo
return true;
}
static C4Object *FnGetCursor(C4AulContext *cthr, long iPlr, long iIndex)
static C4Object *FnGetCursor(C4AulContext *cthr, long iPlr)
{
// get player
C4Player *pPlr = ::Players.Get(iPlr);
// invalid player?
if (!pPlr) return NULL;
// first index is always the cursor
if (!iIndex) return pPlr->Cursor;
// iterate through selected crew for iIndex times
// status needs not be checked, as dead objects are never in Crew list
C4Object *pCrew;
for (C4ObjectLink *pLnk=pPlr->Crew.First; pLnk; pLnk=pLnk->Next)
// get crew object
if ((pCrew = pLnk->Obj))
// is it selected?
if (pCrew->Select)
// is it not the cursor? (which is always first)
if (pCrew != pPlr->Cursor)
// enough searched?
if (!--iIndex)
// return it
return pCrew;
// nothing found at that index
return NULL;
return pPlr->Cursor;
}
static C4Object *FnGetViewCursor(C4AulContext *cthr, long iPlr)
@ -2756,12 +2734,11 @@ static C4Object *FnGetViewCursor(C4AulContext *cthr, long iPlr)
return pPlr ? pPlr->ViewCursor : NULL;
}
static bool FnSetCursor(C4AulContext *cthr, long iPlr, C4Object *pObj, bool fNoSelectMark, bool fNoSelectArrow, bool fNoSelectCrew)
static bool FnSetCursor(C4AulContext *cthr, long iPlr, C4Object *pObj, bool fNoSelectArrow)
{
C4Player *pPlr = ::Players.Get(iPlr);
if (!pPlr || (pObj && !pObj->Status) || (pObj && pObj->CrewDisabled)) return false;
pPlr->SetCursor(pObj, !fNoSelectMark, !fNoSelectArrow);
if (!fNoSelectCrew) pPlr->SelectCrew(pObj, true);
pPlr->SetCursor(pObj, !fNoSelectArrow);
return true;
}
@ -2776,28 +2753,6 @@ static bool FnSetViewCursor(C4AulContext *cthr, long iPlr, C4Object *pObj)
return true;
}
static bool FnSelectCrew(C4AulContext *cthr, long iPlr, C4Object *pObj, bool fSelect, bool fNoCursorAdjust)
{
C4Player *pPlr = ::Players.Get(iPlr);
if (!pPlr || !pObj) return false;
if (fNoCursorAdjust)
{ if (fSelect) pObj->DoSelect(); else pObj->UnSelect(); }
else
pPlr->SelectCrew(pObj,fSelect);
return true;
}
static bool FnGetCrewSelected(C4AulObjectContext *cthr)
{
return !!cthr->Obj->Select;
}
static long FnGetSelectCount(C4AulContext *cthr, long iPlr)
{
if (!ValidPlr(iPlr)) return false;
return ::Players.Get(iPlr)->SelectCount;
}
static bool FnSetCrewStatus(C4AulObjectContext *cthr, long iPlr, bool fInCrew)
{
// validate player
@ -4210,7 +4165,6 @@ static C4Void FnSetCrewEnabled(C4AulObjectContext *cctx, bool fEnabled)
// deselect
if (!fEnabled)
{
cctx->Obj->Select=false;
C4Player *pOwner;
if ((pOwner=::Players.Get(cctx->Obj->Owner)))
{
@ -4236,17 +4190,6 @@ static C4Void FnSetCrewEnabled(C4AulObjectContext *cctx, bool fEnabled)
return C4VNull;
}
static bool FnUnselectCrew(C4AulContext *cctx, long iPlayer)
{
// get player
C4Player *pPlr=::Players.Get(iPlayer);
if (!pPlr) return false;
// unselect crew
pPlr->UnselectCrew();
// success
return true;
}
static long FnDrawMap(C4AulContext *cctx, long iX, long iY, long iWdt, long iHgt, C4String *szMapDef)
{
// draw it!
@ -6175,7 +6118,6 @@ void InitFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "DoPlayerScore", FnDoPlayerScore);
AddFunc(pEngine, "GetPlayerScore", FnGetPlayerScore);
AddFunc(pEngine, "GetPlayerScoreGain", FnGetPlayerScoreGain);
AddFunc(pEngine, "GetPlrControlName", FnGetPlrControlName);
AddFunc(pEngine, "GetWind", FnGetWind);
AddFunc(pEngine, "SetWind", FnSetWind);
AddFunc(pEngine, "GetTemperature", FnGetTemperature);
@ -6205,9 +6147,6 @@ void InitFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "GetViewCursor", FnGetViewCursor);
AddFunc(pEngine, "SetCursor", FnSetCursor);
AddFunc(pEngine, "SetViewCursor", FnSetViewCursor);
AddFunc(pEngine, "SelectCrew", FnSelectCrew);
AddFunc(pEngine, "GetCrewSelected", FnGetCrewSelected);
AddFunc(pEngine, "GetSelectCount", FnGetSelectCount);
AddFunc(pEngine, "SetCrewStatus", FnSetCrewStatus, false);
AddFunc(pEngine, "SetPosition", FnSetPosition);
AddFunc(pEngine, "GetMaterial", FnGetMaterial);
@ -6285,7 +6224,6 @@ void InitFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "GetNeededMatStr", FnGetNeededMatStr);
AddFunc(pEngine, "GetCrewEnabled", FnGetCrewEnabled);
AddFunc(pEngine, "SetCrewEnabled", FnSetCrewEnabled);
AddFunc(pEngine, "UnselectCrew", FnUnselectCrew);
AddFunc(pEngine, "DrawMap", FnDrawMap);
AddFunc(pEngine, "DrawDefMap", FnDrawDefMap);
AddFunc(pEngine, "CreateParticle", FnCreateParticle);

View File

@ -1260,6 +1260,10 @@ void C4Viewport::DrawPlayerInfo(C4TargetFacet &cgo)
C4Facet ccgo;
if (!ValidPlr(Player)) return;
/* C4Player * pPlr = ::Players.Get(Player);
if (pPlr->SelectFlash && pPlr->Cursor)
pPlr->Cursor->DrawSelectMark(cgo, 1); */
// Controls
DrawPlayerStartup(cgo);
@ -1302,41 +1306,6 @@ bool C4Viewport::Init(CStdWindow * pParent, CStdApp * pApp, int32_t iPlayer)
return true;
}
StdStrBuf PlrControlKeyName(int32_t iPlayer, int32_t iControl, bool fShort)
{
// determine player
C4Player *pPlr = ::Players.Get(iPlayer);
// player control
if (pPlr)
{
if (pPlr && pPlr->ControlSet)
{
C4PlayerControlAssignment *ass = pPlr->ControlSet->GetAssignmentByControl(iControl);
if (ass)
{
return C4KeyCodeEx::KeyCode2String(ass->GetTriggerKey().Key, true, fShort);
}
}
}
// global control
else
{
// look up iControl for a matching mapping in global key map
// and then display the key name - should at least work for
// stuff in KEYSCOPE_FullSMenu...
const char *szKeyID;
switch (iControl)
{
case CON_Throw: szKeyID = "FullscreenMenuOK"; break;
case CON_Dig: szKeyID = "FullscreenMenuCancel"; break;
default: szKeyID = NULL; break;
}
if (szKeyID) return Game.KeyboardInput.GetKeyCodeNameByKeyName(szKeyID, fShort);
}
// undefined control
return StdStrBuf();
}
extern int32_t DrawMessageOffset;
void C4Viewport::DrawPlayerStartup(C4TargetFacet &cgo)