OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Player.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Player data at runtime */
19 
20 #include "C4Include.h"
21 #include "player/C4Player.h"
22 
23 #include "game/C4Application.h"
24 #include "object/C4Def.h"
25 #include "object/C4DefList.h"
26 #include "object/C4Object.h"
27 #include "object/C4ObjectInfo.h"
28 #include "object/C4Command.h"
29 #include "network/C4League.h"
31 #include "gui/C4MessageInput.h"
32 #include "platform/C4GamePadCon.h"
33 #include "lib/C4Random.h"
34 #include "lib/C4Log.h"
35 #include "game/C4FullScreen.h"
36 #include "gui/C4GameOverDlg.h"
37 #include "object/C4ObjectMenu.h"
38 #include "gui/C4MouseControl.h"
39 #include "gui/C4GameMessage.h"
41 #include "game/C4GraphicsSystem.h"
42 #include "landscape/C4Landscape.h"
43 #include "game/C4Game.h"
44 #include "player/C4PlayerList.h"
45 #include "object/C4GameObjects.h"
46 #include "control/C4GameControl.h"
47 #include "game/C4Viewport.h"
48 
50 {
51  Filename[0] = 0;
53  ID = 0;
54  Team = 0;
56  Menu.Default();
57  Crew.Default();
59  LocalControl = false;
60  BigIcon.Default();
61  Next = nullptr;
62  fFogOfWar = true;
63  LeagueEvaluated = false;
64  GameJoinTime = 0; // overwritten in Init
65  pstatControls = pstatActions = nullptr;
68  LastControlID = 0;
69  pMsgBoardQuery = nullptr;
70  NoEliminationCheck = false;
71  Evaluated = false;
74  ViewLock = true;
76 }
77 
79 {
80  ClearGraphs();
81  Menu.Clear();
82  SetSoundModifier(nullptr);
83  while (pMsgBoardQuery)
84  {
86  delete pMsgBoardQuery;
87  pMsgBoardQuery = pNext;
88  }
89  ClearControl();
90 }
91 
93 {
94  if (!tobj) return false;
95  for (C4Object *cobj : Crew)
96  if (cobj==tobj) return true;
97  return false;
98 }
99 
100 void C4Player::ClearPointers(C4Object *pObj, bool fDeath)
101 {
102  // Crew
103  while (Crew.Remove(pObj)) {}
104  // View-Cursor
105  if (ViewCursor==pObj) ViewCursor = nullptr;
106  // View
107  if (ViewTarget==pObj) ViewTarget=nullptr;
108  // Cursor
109  if (Cursor == pObj)
110  {
111  // object is to be deleted; do NOT do script calls (like in Cursor->UnSelect(true))
112  Cursor = nullptr; AdjustCursorCommand(); // also selects and eventually does a script call!
113  }
114  // Menu
115  Menu.ClearPointers(pObj);
116  // messageboard-queries
118 }
119 
120 bool C4Player::ScenarioAndTeamInit(int32_t idTeam)
121 {
122  C4PlayerInfo *pInfo = GetInfo();
123  if (!pInfo) return false;
124  C4Team *pTeam;
125  if (idTeam == TEAMID_New)
126  {
127  // creation of a new team only if allowed by scenario
129  pTeam = nullptr;
130  else
131  {
132  if ((pTeam = Game.Teams.GetGenerateTeamByID(idTeam))) idTeam = pTeam->GetID();
133  }
134  }
135  else
136  {
137  // uage of an existing team
138  pTeam = Game.Teams.GetTeamByID(idTeam);
139  }
140  C4Team *pPrevTeam = Game.Teams.GetTeamByID(Team);
141  // check if join to team is possible; e.g. not too many players
142  if (pPrevTeam != pTeam && idTeam)
143  {
144  if (!Game.Teams.IsJoin2TeamAllowed(idTeam, pInfo->GetType()))
145  {
146  pTeam = nullptr;
147  }
148  }
149  if (!pTeam && idTeam)
150  {
152  return false;
153  }
154  // team selection OK; execute it!
155  if (pPrevTeam) pPrevTeam->RemovePlayerByID(pInfo->GetID());
156  if (pTeam) pTeam->AddPlayer(*pInfo, true);
157  if (!ScenarioInit()) return false;
158  if (!FinalInit(false)) return false;
159  // perform any pending InitializePlayers() callback
161  return true;
162 }
163 
165 {
166  if (!Status) return;
167 
168  // Open/refresh team menu if desired
170  {
171  int32_t idSelectedTeam;
172  if ((idSelectedTeam = Game.Teams.GetForcedTeamSelection(ID)))
173  {
174  // There's only one team left to join? Join there immediately.
175  if (Menu.IsActive() && Menu.GetIdentification() == C4MN_TeamSelection) Menu.TryClose(false, false);
176  if (LocalControl && !::Control.isReplay())
177  {
178  // team selection done through queue because TeamSelection-status may not be in sync (may be TeamSelectionPending!)
179  DoTeamSelection(idSelectedTeam);
180  }
181  }
182  else if (!Menu.IsActive()) ActivateMenuTeamSelection(false);
183  else
184  {
185  // during team selection: Update view to selected team, if it has a position assigned
186  C4MenuItem *pSelectedTeamItem;
187  if ((pSelectedTeamItem = Menu.GetSelectedItem()))
188  {
189  int32_t idSelectedTeam = atoi(pSelectedTeamItem->GetCommand()+8);
190  if (idSelectedTeam)
191  {
192  C4Team *pSelectedTeam;
193  if ((pSelectedTeam = Game.Teams.GetTeamByID(idSelectedTeam)))
194  {
195  int32_t iPlrStartIndex = pSelectedTeam->GetPlrStartIndex();
196  if (iPlrStartIndex && Inside<int32_t>(iPlrStartIndex, 1, C4S_MaxPlayer))
197  {
198  if (Game.C4S.PlrStart[iPlrStartIndex-1].Position[0] > -1)
199  {
200  // player has selected a team that has a valid start position assigned
201  // set view to this position!
202  ViewX = Game.C4S.PlrStart[iPlrStartIndex-1].Position[0] * ::Landscape.GetMapZoom();
203  ViewY = Game.C4S.PlrStart[iPlrStartIndex-1].Position[1] * ::Landscape.GetMapZoom();
204  }
205  }
206  }
207  }
208  }
209  }
210  }
212  {
213  Menu.TryClose(false, false);
214  }
215 
216  // Do we have a gamepad?
217  if (pGamepad)
218  {
219  // Check whether it's still connected.
220  if (!pGamepad->IsAttached())
221  {
222  // Allow the player to plug the gamepad back in. This allows
223  // battery replacement or plugging the controller back
224  // in after someone tripped over the wire.
225  if (!FindGamepad())
226  {
227  LogF("%s: No gamepad available.", Name.getData());
228  ::Game.Pause();
229  }
230  }
231  }
232  // Should we have one? The player may have started the game
233  // without turning their controller on, only noticing this
234  // after the game started.
235  else if (LocalControl && ControlSet && ControlSet->HasGamepad())
236  {
237  FindGamepad();
238  }
239 
240  // Tick1
241  UpdateView();
242  ExecuteControl();
243  Menu.Execute();
244 
245  // ::Game.iTick35
246  if (!::Game.iTick35 && Status==PS_Normal)
247  {
250  if (pMsgBoardQuery && LocalControl) ExecMsgBoardQueries();
251  }
252 
253  // Delays
254  if (MessageStatus>0) MessageStatus--;
255  if (RetireDelay>0) RetireDelay--;
256  if (CursorFlash>0) CursorFlash--;
257 }
258 
259 bool C4Player::Init(int32_t iNumber, int32_t iAtClient, const char *szAtClientName,
260  const char *szFilename, bool fScenarioInit, class C4PlayerInfo *pInfo, C4ValueNumbers * numbers)
261 {
262  // safety
263  if (!pInfo)
264  {
265  LogF("ERROR: Init player %s failed: No info!", szFilename);
266  assert(false);
267  return false;
268  }
269  // Status init
271  Number = iNumber;
272  ID = pInfo->GetID();
273  Team = pInfo->GetTeam();
275 
276  // At client
277  AtClient=iAtClient; SCopy(szAtClientName,AtClientName,C4MaxTitle);
278 
279  if (szFilename)
280  {
281  // Load core & crew info list
282  if (!Load(szFilename, !fScenarioInit)) return false;
283  }
284  else
285  {
286  // no core file present: Keep defaults
287  // This can happen for script players only
288  assert(pInfo->GetType() == C4PT_Script);
289  }
290 
291  // Take player name from player info; forcing overloads by the league or because of doubled player names
292  Name.Copy(pInfo->GetName());
293 
294  // view pos init: Start at center pos
296 
297  // Scenario init
298  if (fScenarioInit)
299  {
300  // mark player join in player info list
301  // for non-scenarioinit, player should already be marked as joined
302  pInfo->SetJoined(iNumber);
303 
304  // Number might have changed: Recheck list sorting before scenarioinit, which will do script calls
306 
307  // check for a postponed scenario init, if no team is specified (post-lobby-join in network, or simply non-network)
308  C4Team *pTeam = nullptr;
309  if (Team)
310  {
313  else
314  pTeam = Game.Teams.GetTeamByID(Team);
315  }
316  if (!pTeam && Game.Teams.IsRuntimeJoinTeamChoice())
317  {
318  if (pInfo->GetType() == C4PT_Script)
319  {
320  // script player without team: This can usually not happen, because RecheckPlayerInfoTeams should have been executed
321  // just leave this player without the team
322  assert(false);
323  }
324  else
325  {
326  // postponed init: Chose team first
328  }
329  }
330 
331  // Init control method before scenario init, because script callbacks may need to know it!
332  ClearControl();
333  InitControl();
334 
335  // defaultdisabled controls
336  Control.Init();
337 
338  // Special: Script players may skip scenario initialization altogether, and just desire a single callback to all objects
339  // of a given ID
340  if (!pInfo->IsScenarioInitDesired())
341  {
342  // only initialization that's done anyway is team hostility
343  if (Team) SetTeamHostility();
344  // callback definition passed?
345  C4ID idCallback = pInfo->GetScriptPlayerExtraID();
346  C4Def *pDefCallback;
347  if (idCallback && (pDefCallback = C4Id2Def(idCallback)))
348  {
350  }
351  }
352  else
353  {
354  // player preinit: In case a team needs to be chosen first, no InitializePlayer-broadcast is done
355  // this callback shall give scripters a chance to do stuff like starting an intro or enabling FoW, which might need to be done
357  // direct init
358  if (Status != PS_TeamSelection) if (!ScenarioInit()) return false;
359  }
360  }
361 
362  // Load runtime data
363  else
364  {
365  assert(pInfo->IsJoined());
366  assert(numbers);
367  // (compile using DefaultRuntimeData) - also check if compilation returned sane results, i.e. ID assigned
368  if (!LoadRuntimeData(Game.ScenarioFile, numbers) || !ID)
369  {
370  // for script players in non-savegames, this is OK - it means they get restored using default values
371  // this happens when the users saves a scenario using the "Save scenario"-option while a script player
372  // was joined
373  if (!Game.C4S.Head.SaveGame && pInfo->GetType() == C4PT_Script)
374  {
375  Number = pInfo->GetInGameNumber();
376  ColorDw = pInfo->GetColor();
377  ID = pInfo->GetID();
378  Team = pInfo->GetTeam();
379  }
380  else
381  return false;
382  }
383  // Reset values default-overriden by old runtime data load (safety?)
384  if (Number==C4P_Number_None) Number=iNumber;
385  if (szFilename) SCopy(Config.AtUserDataPath(szFilename),Filename); else *Filename='\0';
386  // NET2: Direct joins always send accurate client IDs and names in params
387  // do not overwrite them with savegame data, because players might as well
388  // change clients
389  // (only call should be savegame recreation by C4PlayerInfoList::RecreatePlayers)
390  AtClient = iAtClient;
391  SCopy(szAtClientName,AtClientName,C4MaxTitle);
392  // Number might have changed: Recheck list sorting
394  // Init control after loading runtime data, because control init will overwrite some of the values
395  InitControl();
396  }
397 
398  // store game joining time
400 
401  // Init FoW-viewobjects: NO_OWNER-FoW-repellers might need to be added
402  for (C4Object *pObj : Objects)
403  {
404  if ((pObj->lightRange || pObj->lightFadeoutRange) && pObj->Owner == NO_OWNER)
405  pObj->UpdateLight();
406  }
407 
408  // init graphs
410 
411  // init sound mod
413 
414  return true;
415 }
416 
418 {
419  C4Group hGroup;
420  // Regular player saving need not be done for script players
421  if (GetType() == C4PT_Script) return false;
422  // Log
423  LogF(LoadResStr("IDS_PRC_SAVEPLR"), Config.AtRelativePath(Filename));
424  ::GraphicsSystem.MessageBoard->EnsureLastMessage();
425  // copy player to save somewhere else
426  char szPath[_MAX_PATH + 1];
428  MakeTempFilename(szPath);
429  // For local players, we save over the old player file, as there might
430  // be all kinds of non-essential stuff in it. For non-local players, we
431  // just re-create it every time (it's temporary anyway).
432  if (LocalControl)
433  {
434  // But make sure to copy it first so full hard (flgr stupid) disks
435  // won't corrupt any player files...
436  C4Group_CopyItem(Filename, szPath);
437  }
438  else
439  {
440  // For non-local players, we can actually use the loaded definition
441  // list to strip out all non-existant definitions. This is only valid
442  // because we know the file to be temporary.
444  }
445  // Open group
446  if (!hGroup.Open(szPath,true))
447  return false;
448  // Save
449  if (!Save(hGroup, false, !LocalControl))
450  { hGroup.Close(); return false; }
451  // Close group
452  if (!hGroup.Close()) return false;
453  // resource
455  pDRes = nullptr;
456  bool fOfficial = pRes && ::Control.isCtrlHost();
457  if (pRes) pDRes = pRes->Derive();
458  // move back
460  if (!C4Group_MoveItem(szPath, Filename)) return false;
461  // finish update
462  if (pDRes && fOfficial) pDRes->FinishDerive();
463  // Success
464  return true;
465 }
466 
467 bool C4Player::Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny)
468 {
469  // Save core
470  if (!C4PlayerInfoCore::Save(hGroup))
471  return false;
472  // Save crew
473  C4DefList *pDefs = &::Definitions;
474  if (!CrewInfoList.Save(hGroup, fSavegame, fStoreTiny, pDefs))
475  { hGroup.Close(); return false; }
476  // Sort
477  hGroup.Sort(C4FLS_Player);
478  return true;
479 }
480 
481 void C4Player::PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
482 {
483  int32_t cnt,ctx,cty;
484  C4Object *nobj;
485  C4ObjectInfo *pInfo;
486  C4Def *pDef;
487 
488  // Place crew
489  int32_t iCount;
490  C4ID id;
491  for (cnt=0; (id=Game.C4S.PlrStart[PlrStartIndex].ReadyCrew.GetID(cnt,&iCount)); cnt++)
492  {
493  // Minimum one clonk if empty id
494  iCount = std::max<int32_t>(iCount,1);
495 
496  for (int32_t cnt2=0; cnt2<iCount; cnt2++)
497  {
498  // Select member from home crew, add new if necessary
499  while (!(pInfo=CrewInfoList.GetIdle(id,::Definitions)))
500  if (!CrewInfoList.New(id,&::Definitions))
501  break;
502  // Safety
503  if (!pInfo || !(pDef=C4Id2Def(pInfo->id))) continue;
504  // Crew placement location
505  ctx=tx1+Random(tx2-tx1); cty=ty;
507  FindSolidGround(ctx,cty,pDef->Shape.Wdt*3);
508  // Create object
509  if ((nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty)))
510  {
511  // Add object to crew
513  // add visibility range
514  nobj->SetLightRange(C4FOW_DefLightRangeX, C4FOW_DefLightFadeoutRangeX);
515  // If base is present, enter base
516  if (FirstBase) { nobj->Enter(FirstBase); nobj->SetCommand(C4CMD_Exit); }
517  // OnJoinCrew callback
518  {
519 #if !defined(DEBUGREC_RECRUITMENT)
520  C4DebugRecOff DbgRecOff;
521 #endif
522  C4AulParSet parset(Number);
523  nobj->Call(PSF_OnJoinCrew, &parset);
524  }
525  }
526  }
527  }
528 
529 }
530 
531 void C4Player::PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
532 {
533  int32_t cnt,cnt2,ctx,cty;
534  C4Def *def;
535  C4ID cid;
536  C4Object *cbase;
537  // Create ready base structures
538  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetID(cnt)); cnt++)
539  {
540  if ((def=C4Id2Def(cid)))
541  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetCount(cnt); cnt2++)
542  {
543  ctx=tx; cty=ty;
545  || FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,20))
546  if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),nullptr,Number,ctx,cty,FullCon,true)))
547  {
548  // FirstBase
549  if (!(*pFirstBase)) if ((cbase->Def->Entrance.Wdt>0) && (cbase->Def->Entrance.Hgt>0))
550  { *pFirstBase=cbase; tx=(*pFirstBase)->GetX(); ty=(*pFirstBase)->GetY(); }
551  }
552  }
553  }
554 }
555 
556 void C4Player::PlaceReadyVehic(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
557 {
558  int32_t cnt,cnt2,ctx,cty;
559  C4Def *def; C4ID cid; C4Object *cobj;
560  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetID(cnt)); cnt++)
561  {
562  if ((def=C4Id2Def(cid)))
563  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetCount(cnt); cnt2++)
564  {
565  ctx=tx1+Random(tx2-tx1); cty=ty;
567  FindLevelGround(ctx,cty,def->Shape.Wdt,6);
568  if ((cobj=Game.CreateObject(cid,nullptr,Number,ctx,cty)))
569  {
570  if (FirstBase) // First base overrides target location
571  { cobj->Enter(FirstBase); cobj->SetCommand(C4CMD_Exit); }
572  }
573  }
574  }
575 }
576 
577 void C4Player::PlaceReadyMaterial(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
578 {
579  int32_t cnt,cnt2,ctx,cty;
580  C4Def *def; C4ID cid;
581 
582  // In base
583  if (FirstBase)
584  {
586  }
587 
588  // Outside
589  else
590  {
591  for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetID(cnt)); cnt++)
592  {
593  if ((def=C4Id2Def(cid)))
594  for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetCount(cnt); cnt2++)
595  {
596  ctx=tx1+Random(tx2-tx1); cty=ty;
598  FindSolidGround(ctx,cty,def->Shape.Wdt);
599  Game.CreateObject(cid,nullptr,Number,ctx,cty);
600  }
601  }
602  }
603 }
604 
606 {
607  int32_t ptx,pty;
608 
609  // player start index by team, if specified. Otherwise by player number
611  C4Team *pTeam; int32_t i;
612  if (Team && (pTeam = Game.Teams.GetTeamByID(Team))) if ((i=pTeam->GetPlrStartIndex())) PlrStartIndex=i-1;
613 
614  C4PlayerInfo *pInfo = GetInfo();
615  if (!pInfo) { assert(false); LogF("Internal error: ScenarioInit for ghost player %s!", GetName()); return false; }
616 
617  // set color by player info class
618  // re-setting, because runtime team choice may have altered color
619  ColorDw = pInfo->GetColor();
620 
621  // any team selection is over now
622  Status = PS_Normal;
623 
624  // Wealth, home base materials, abilities
632 
633  // Starting position
636 
637  // Zoomed position
638  if (ptx>-1) ptx = Clamp<int32_t>( ptx * Game.C4S.Landscape.MapZoom.Evaluate(), 0, ::Landscape.GetWidth()-1 );
639  if (pty>-1) pty = Clamp<int32_t>( pty * Game.C4S.Landscape.MapZoom.Evaluate(), 0, ::Landscape.GetHeight()-1 );
640 
641  // Standard position (PrefPosition)
642  if (ptx<0)
643  if (Game.StartupPlayerCount>=2)
644  {
645  int32_t iMaxPos=Game.StartupPlayerCount;
646  // Try to initialize PrefPosition using teams. This should put players of a team next to each other.
647  int PrefPosition = 0;
648  C4PlayerInfo *plr;
649  for (int i = 0; (plr = Game.PlayerInfos.GetPlayerInfoByIndex(i)) != nullptr; i++)
650  {
651  if (plr->GetTeam() < Team)
652  PrefPosition++;
653  }
654  // Map preferred position to available positions
655  int32_t iStartPos=Clamp(PrefPosition*iMaxPos/C4P_MaxPosition,0,iMaxPos-1);
656  int32_t iPosition=iStartPos;
657  // Distribute according to availability
658  while (::Players.PositionTaken(iPosition))
659  {
660  ++iPosition;
661  iPosition %= iMaxPos;
662  if (iPosition == iStartPos)
663  break;
664  }
665  Position=iPosition;
666  // Set x position
667  ptx=Clamp(16+Position*(::Landscape.GetWidth()-32)/(iMaxPos-1),0,::Landscape.GetWidth()-16);
668  }
669 
670  // All-random position
671  if (ptx<0) ptx=16+Random(::Landscape.GetWidth()-32);
672  if (pty<0) pty=16+Random(::Landscape.GetHeight()-32);
673 
674  // Place to solid ground
676  {
677  // Use nearest above-ground...
678  FindSolidGround(ptx,pty,30);
679  // Might have hit a small lake, or similar: Seach a real site spot from here
680  FindConSiteSpot(ptx, pty, 30, 50, 400);
681  }
682 
683  // Place Readies
684  C4Object *FirstBase = nullptr;
685  PlaceReadyBase(ptx,pty,&FirstBase);
686  PlaceReadyMaterial(ptx-10,ptx+10,pty,FirstBase);
687  PlaceReadyVehic(ptx-30,ptx+30,pty,FirstBase);
688  PlaceReadyCrew(ptx-30,ptx+30,pty,FirstBase);
689 
690  // set initial hostility by team info
691  if (Team) SetTeamHostility();
692 
693  // Scenario script initialization
695  ptx,
696  pty,
697  FirstBase,
698  Team,
699  C4Id2Def(GetInfo()->GetScriptPlayerExtraID())));
700  return true;
701 }
702 
703 bool C4Player::FinalInit(bool fInitialScore)
704 {
705  if (!Status) return true;
706 
707  // Init player's mouse control
708  if (LocalControl)
709  if (MouseControl)
710  ::MouseControl.Init(Number);
711 
712  // Set initial score
713  if (fInitialScore)
714  {
716  }
717 
718  // Cursor
719  if (!Cursor) AdjustCursorCommand();
720 
721  // Update counts, pointers, views
722  Execute();
723 
724  return true;
725 }
726 
727 void C4Player::SetFoW(bool fEnable)
728 {
729  // set flag
730  fFogOfWar = fEnable;
731 }
732 
733 bool C4Player::DoWealth(int32_t iChange)
734 {
735  if (LocalControl)
736  {
737  if (iChange>0) StartSoundEffect("UI::Cash");
738  if (iChange<0) StartSoundEffect("UI::UnCash");
739  }
740  SetWealth(Wealth+iChange);
741 
742  return true;
743 }
744 
745 bool C4Player::SetWealth(int32_t iVal)
746 {
747  if (iVal == Wealth) return true;
748 
749  Wealth=Clamp<int32_t>(iVal,0,1000000000);
750 
752 
753  return true;
754 }
755 
756 bool C4Player::SetKnowledge(C4ID id, bool fRemove)
757 {
758  if (fRemove)
759  {
760  long iIndex = Knowledge.GetIndex(id);
761  if (iIndex<0) return false;
762  return Knowledge.DeleteItem(iIndex);
763  }
764  else
765  {
766  if (!C4Id2Def(id)) return false;
767  return Knowledge.SetIDCount(id, 1, true);
768  }
769 }
770 
771 void C4Player::SetViewMode(int32_t iMode, C4Object *pTarget, bool immediate_position)
772 {
773  // safe back
774  ViewMode=iMode; ViewTarget=pTarget;
775  // immediate position set desired?
776  if (immediate_position)
777  {
778  UpdateView();
780  if (vp) vp->AdjustPosition(true);
781  }
782 }
783 
784 void C4Player::ResetCursorView(bool immediate_position)
785 {
786  // reset view to cursor if any cursor exists
787  if (!ViewCursor && !Cursor) return;
788  SetViewMode(C4PVM_Cursor, nullptr, immediate_position);
789 }
790 
792 {
793  // do not evaluate twice
794  if (Evaluated) return;
795 
796  const int32_t SuccessBonus=100;
797 
798  // Set last round
800  time(reinterpret_cast<time_t *>(&LastRound.Date));
803  // Melee: personal value gain score ...check ::Objects(C4D_Goal)
804  if (Game.C4S.Game.IsMelee()) LastRound.Score = std::max<int32_t>(CurrentScore-InitialScore,0);
805  // Cooperative: shared score
806  else LastRound.Score = std::max(::Players.AverageScoreGain(),0);
807  LastRound.Level = 0; // unknown...
808  LastRound.Bonus = SuccessBonus * LastRound.Won;
811 
812  // Update player
813  Rounds++;
814  if (LastRound.Won) RoundsWon++; else RoundsLost++;
817 
818  // Crew
820 
821  // league
822  if (Game.Parameters.isLeague())
824 
825  // Player is now evaluated
826  Evaluated = true;
827 
828  // round results
830 }
831 
833 {
834  if (Surrendered) return;
835  Surrendered=true;
836  Eliminated=true;
838  StartSoundEffect("UI::Eliminated");
839  Log(FormatString(LoadResStr("IDS_PRC_PLRSURRENDERED"),GetName()).getData());
840 }
841 
842 bool C4Player::SetHostility(int32_t iOpponent, int32_t hostile, bool fSilent)
843 {
844  assert(hostile == 0 || hostile == 1);
845  // Check opponent valid
846  C4Player *opponent = ::Players.Get(iOpponent);
847  if (!opponent || opponent == this)
848  return false;
849  // Set hostility
850  if (hostile)
851  Hostility.insert(opponent);
852  else
853  Hostility.erase(opponent);
854  // no announce in first frame, or if specified
855  if (!Game.FrameCounter || fSilent) return true;
856  // Announce
857  StartSoundEffect("UI::Trumpet");
858  Log(FormatString(LoadResStr(hostile ? "IDS_PLR_HOSTILITY" : "IDS_PLR_NOHOSTILITY"),
859  GetName(),opponent->GetName()).getData());
860  // Success
861  return true;
862 }
863 
864 bool C4Player::IsHostileTowards(const C4Player *plr) const
865 {
866  assert(plr);
867  if (!plr) return false;
868  return Hostility.find(plr) != Hostility.end();
869 }
870 
872 {
873  C4Object *hiexp=nullptr;
874  int32_t iHighestExp=-2, iExp;
875  for (C4Object *cobj : Crew)
876  {
877  if (!cobj->CrewDisabled)
878  {
879  if (cobj->Info) iExp = cobj->Info->Experience; else iExp=-1;
880  if (!hiexp || (iExp>iHighestExp))
881  {
882  hiexp=cobj;
883  iHighestExp=iExp;
884  }
885  }
886  }
887  return hiexp;
888 }
889 
891 {
892  C4Object *hirank=nullptr;
893  int32_t iHighestRank=-2, iRank;
894  for (C4Object *cobj : Crew)
895  {
896  if (!cobj->CrewDisabled)
897  {
898  if (cobj->Info) iRank = cobj->Info->Rank; else iRank=-1;
899  if (!hirank || (iRank>iHighestRank))
900  {
901  hirank=cobj;
902  iHighestRank=iRank;
903  }
904  }
905  }
906  return hirank;
907 }
908 
910 {
911  C4Object *hirank;
912  if ((hirank=GetHiRankActiveCrew()))
913  if (hirank->Info)
914  if (hirank->Info->Rank<1) // No Fähnrich -> except. promo.
915  if ((hirank=GetHiExpActiveCrew()))
916  hirank->Promote(1,true,false);
917 }
918 
920 {
921  // team only
922  if (!Team) return;
923  // set hostilities
924  for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next)
925  if (pPlr != this)
926  {
927  bool fHostile = (pPlr->Team != Team);
928  SetHostility(pPlr->Number, fHostile, true);
929  pPlr->SetHostility(Number, fHostile, true);
930  }
931 }
932 
933 bool C4Player::Message(const char *szMsg)
934 {
935  if (!szMsg) return false;
936  SCopy(szMsg,MessageBuf,256);
937  MessageStatus=SLen(szMsg)*2;
938  return true;
939 }
940 
941 bool C4Player::Load(const char *szFilename, bool fSavegame)
942 {
943  C4Group hGroup;
944  // Open group
945  if (!Reloc.Open(hGroup, szFilename)) return false;
946  // Remember filename
948  // Load core
949  if (!C4PlayerInfoCore::Load(hGroup))
950  { hGroup.Close(); return false; }
951  // Load BigIcon
952  if (hGroup.FindEntry(C4CFN_BigIcon)) BigIcon.Load(hGroup, C4CFN_BigIcon, C4FCT_Full, C4FCT_Full, false, 0);
953  // Load crew info list
954  CrewInfoList.Load(hGroup);
955  // Close group
956  hGroup.Close();
957  // Success
958  return true;
959 }
960 
961 bool C4Player::Strip(const char *szFilename, bool fAggressive)
962 {
963  // Open group
964  C4Group Grp;
965  if (!Grp.Open(szFilename))
966  return false;
967  // Which type of stripping?
968  if (!fAggressive)
969  {
970  // remove bigicon, if the file size is too large
971  size_t iBigIconSize=0;
972  if (Grp.FindEntry(C4CFN_BigIcon, nullptr, &iBigIconSize))
973  if (iBigIconSize > C4NetResMaxBigicon*1024)
974  Grp.Delete(C4CFN_BigIcon);
975  Grp.Close();
976  }
977  else
978  {
979  // Load info core and crew info list
980  C4PlayerInfoCore PlrInfoCore;
982  if (!PlrInfoCore.Load(Grp) || !CrewInfoList.Load(Grp))
983  return false;
984  // Strip crew info list (remove object infos that are invalid for this scenario)
985  CrewInfoList.Strip(::Definitions);
986  // Create a new group that receives the bare essentials
987  Grp.Close();
988  if (!EraseItem(szFilename) ||
989  !Grp.Open(szFilename, true))
990  return false;
991  // Save info core & crew info list to newly-created file
992  if (!PlrInfoCore.Save(Grp) || !CrewInfoList.Save(Grp, true, true, &::Definitions))
993  return false;
994  Grp.Close();
995  }
996  return true;
997 }
998 
999 void C4Player::DrawHostility(C4Facet &cgo, int32_t iIndex)
1000 {
1001  C4Player *pPlr;
1002  if ((pPlr=::Players.GetByIndex(iIndex)))
1003  {
1004  ::GraphicsResource.fctCrewClr.DrawClr(cgo, true, pPlr->ColorDw);
1005  // Other player and hostile
1006  if (pPlr != this)
1007  if (Hostility.find(pPlr) != Hostility.end())
1009  }
1010 }
1011 
1012 bool C4Player::MakeCrewMember(C4Object *pObj, bool fForceInfo, bool fDoCalls)
1013 {
1014  C4ObjectInfo *cInf = nullptr;
1015  if (!pObj || !pObj->Def->CrewMember || !pObj->Status) return false;
1016 
1017  // only if info is not yet assigned
1018  if (!pObj->Info && fForceInfo)
1019  {
1020  // Find crew info by name
1021  if (pObj->nInfo)
1022  cInf = CrewInfoList.GetIdle(pObj->nInfo.getData());
1023 
1024  // Find crew info by id
1025  if (!cInf)
1026  while (!( cInf = CrewInfoList.GetIdle(pObj->id,::Definitions) ))
1027  if (!CrewInfoList.New(pObj->id,&::Definitions))
1028  return false;
1029 
1030  // Set object info
1031  pObj->Info = cInf;
1032  pObj->SetName(cInf->Name);
1033  }
1034 
1035  // Add to crew
1036  if (!Crew.GetLink(pObj))
1037  Crew.Add(pObj, C4ObjectList::stNone);
1038 
1039  // add light
1040  if (!pObj->lightRange)
1041  pObj->SetLightRange(C4FOW_DefLightRangeX, C4FOW_DefLightFadeoutRangeX);
1042  else
1043  pObj->UpdateLight();
1044 
1045  // controlled by the player
1046  pObj->Controller = Number;
1047 
1048  // OnJoinCrew callback
1049  if (fDoCalls)
1050  {
1051  C4AulParSet parset(Number);
1052  pObj->Call(PSF_OnJoinCrew, &parset);
1053  }
1054 
1055  return true;
1056 }
1057 
1059 {
1060  Control.Execute();
1061 }
1062 
1064 {
1065  // Reset view
1066  ResetCursorView();
1067  // Default cursor to hirank clonk
1068  if (!Cursor || Cursor->CrewDisabled)
1069  {
1070  C4Object *pHiRank = GetHiRankActiveCrew();
1071  if (!pHiRank)
1072  return;
1073  SetCursor(pHiRank,true);
1074  UpdateView();
1075  }
1076 }
1077 
1079 {
1080  assert(ID);
1081 
1082  pComp->Value(mkNamingAdapt(Status, "Status", 0));
1083  pComp->Value(mkNamingAdapt(AtClient, "AtClient", C4ClientIDUnknown));
1084  pComp->Value(mkNamingAdapt(toC4CStr(AtClientName),"AtClientName", "Local"));
1085  pComp->Value(mkNamingAdapt(Number, "Index", C4P_Number_None));
1086  pComp->Value(mkNamingAdapt(ID, "ID", 0));
1087  pComp->Value(mkNamingAdapt(Eliminated, "Eliminated", 0));
1088  pComp->Value(mkNamingAdapt(Surrendered, "Surrendered", 0));
1089  pComp->Value(mkNamingAdapt(Evaluated, "Evaluated", false));
1090  pComp->Value(mkNamingAdapt(ColorDw, "ColorDw", 0u));
1091  pComp->Value(mkNamingAdapt(Position, "Position", 0));
1092  pComp->Value(mkNamingAdapt(ViewMode, "ViewMode", C4PVM_Cursor));
1093  pComp->Value(mkNamingAdapt(ViewX, "ViewX", 0));
1094  pComp->Value(mkNamingAdapt(ViewY, "ViewY", 0));
1095  pComp->Value(mkNamingAdapt(ViewLock, "ViewLock", true));
1096  pComp->Value(mkNamingAdapt(ZoomLimitMinWdt, "ZoomLimitMinWdt", 0));
1097  pComp->Value(mkNamingAdapt(ZoomLimitMinHgt, "ZoomLimitMinHgt", 0));
1098  pComp->Value(mkNamingAdapt(ZoomLimitMaxWdt, "ZoomLimitMaxWdt", 0));
1099  pComp->Value(mkNamingAdapt(ZoomLimitMaxHgt, "ZoomLimitMaxHgt", 0));
1100  pComp->Value(mkNamingAdapt(ZoomWdt, "ZoomWdt", 0));
1101  pComp->Value(mkNamingAdapt(ZoomHgt, "ZoomHgt", 0));
1102  pComp->Value(mkNamingAdapt(ZoomLimitMinVal, "ZoomLimitMinVal", Fix0));
1103  pComp->Value(mkNamingAdapt(ZoomLimitMaxVal, "ZoomLimitMaxVal", Fix0));
1104  pComp->Value(mkNamingAdapt(ZoomVal, "ZoomVal", Fix0));
1105  pComp->Value(mkNamingAdapt(fFogOfWar, "FogOfWar", false));
1106  pComp->Value(mkNamingAdapt(ShowStartup, "ShowStartup", false));
1107  pComp->Value(mkNamingAdapt(Wealth, "Wealth", 0));
1108  pComp->Value(mkNamingAdapt(CurrentScore, "Score", 0));
1109  pComp->Value(mkNamingAdapt(InitialScore, "InitialScore", 0));
1110  pComp->Value(mkNamingAdapt(ObjectsOwned, "ObjectsOwned", 0));
1111  pComp->Value(mkNamingAdapt(Hostility, "Hostile" ));
1112  pComp->Value(mkNamingAdapt(ProductionDelay, "ProductionDelay", 0));
1113  pComp->Value(mkNamingAdapt(ProductionUnit, "ProductionUnit", 0));
1114  pComp->Value(mkNamingAdapt(CursorFlash, "CursorFlash", 0));
1115  pComp->Value(mkNamingAdapt(Cursor, "Cursor", C4ObjectPtr::Null));
1116  pComp->Value(mkNamingAdapt(ViewCursor, "ViewCursor", C4ObjectPtr::Null));
1117  pComp->Value(mkNamingAdapt(MessageStatus, "MessageStatus", 0));
1118  pComp->Value(mkNamingAdapt(toC4CStr(MessageBuf),"MessageBuf", ""));
1119  pComp->Value(mkNamingAdapt(BaseMaterial, "BaseMaterial" ));
1120  pComp->Value(mkNamingAdapt(BaseProduction, "BaseProduction" ));
1121  pComp->Value(mkNamingAdapt(Knowledge, "Knowledge" ));
1122  pComp->Value(mkNamingAdapt(mkParAdapt(Crew, numbers), "Crew" ));
1123  pComp->Value(mkNamingAdapt(CrewInfoList.iNumCreated, "CrewCreated", 0));
1124  pComp->Value(mkNamingPtrAdapt( pMsgBoardQuery, "MsgBoardQueries" ));
1125  pComp->Value(mkNamingAdapt(mkParAdapt(SoundModifier, numbers), "SoundModifier", C4Value()));
1126 
1127  if (pComp->isDeserializer())
1128  {
1129  SoundModifier.Denumerate(numbers);
1130  }
1131 
1132  // Keys held down
1133  pComp->Value(Control);
1134 }
1135 
1137 {
1138  const char *pSource;
1139  // Use loaded game text component
1140  if (!(pSource = Game.GameText.GetData())) return false;
1141  // safety: Do nothing if player section is not even present (could kill initialized values)
1142  if (!SSearch(pSource, FormatString("[Player%i]", ID).getData())) return false;
1143  // Compile (Search player section - runtime data is stored by unique player ID)
1144  // Always compile exact. Exact data will not be present for savegame load, so it does not matter
1145  assert(ID);
1146  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(
1147  mkNamingAdapt(mkParAdapt(*this, numbers), FormatString("Player%i", ID).getData()),
1148  StdStrBuf(pSource),
1150  return false;
1151  // Denumerate pointers
1153  // Success
1154  return true;
1155 }
1156 
1158 {
1159  const int32_t MaxBaseProduction = 25;
1160  ProductionDelay++;
1161  if (ProductionDelay>=60) // Minute Production Unit
1162  {
1164  for (int32_t cnt=0; BaseProduction.GetID(cnt); cnt++)
1165  if (BaseProduction.GetCount(cnt)>0)
1166  if (ProductionUnit % Clamp<int32_t>(11-BaseProduction.GetCount(cnt),1,10) ==0)
1167  if (BaseMaterial.GetIDCount(BaseProduction.GetID(cnt)) < MaxBaseProduction)
1169  }
1170 }
1171 
1173 {
1174  // Standard elimination: no crew
1175  if (!Crew.GetFirstObject())
1176  // Already eliminated safety
1177  if (!Eliminated)
1178  // No automatic elimination desired?
1179  if (!NoEliminationCheck)
1180  // Do elimination!
1181  Eliminate();
1182 }
1183 
1185 {
1186  // view target/cursor
1187  switch (ViewMode)
1188  {
1189  case C4PVM_Cursor:
1190  {
1191  C4Object *pViewObj;
1192  if (!(pViewObj=ViewCursor)) pViewObj=Cursor;
1193  if (pViewObj)
1194  {
1195  ViewX=pViewObj->GetX(); ViewY=pViewObj->GetY();
1196  }
1197  break;
1198  }
1199  case C4PVM_Target:
1200  if (ViewTarget)
1201  {
1203  }
1204  break;
1205  case C4PVM_Scrolling:
1206  break;
1207  }
1208 }
1209 
1211 {
1212  Status=0;
1213  Eliminated=0;
1214  Surrendered=0;
1216  SCopy("Local",AtClientName);
1217  ControlSet = nullptr;
1219  MouseControl=false;
1220  Position=-1;
1221  PlrStartIndex=0;
1222  RetireDelay=0;
1224  ViewX=ViewY=0;
1225  ViewTarget=nullptr;
1226  ShowStartup=true;
1227  Wealth=0;
1229  ObjectsOwned=0;
1231  Cursor=ViewCursor=nullptr;
1232  CursorFlash=30;
1233  MessageStatus=0;
1234  MessageBuf[0]=0;
1235  Hostility.clear();
1238  Knowledge.Default();
1239  FlashCom=0;
1240 }
1241 
1243 {
1244  // Menu symbol/init
1245  bool fSwitch = !(Status==PS_TeamSelection);
1248  Menu.Refill();
1249  // Go back to options menu on close
1250  if (fFromMain) Menu.SetCloseCommand("ActivateMenu:Main");
1251  return true;
1252 }
1253 
1254 void C4Player::DoTeamSelection(int32_t idTeam)
1255 {
1256  // stop team selection. This might close the menu forever if the control gets lost
1257  // let's hope it doesn't!
1260 }
1261 
1263 {
1264  // Crew
1266  // Cursor
1268  // ViewCursor
1270  // messageboard-queries
1271  for (C4MessageBoardQuery *pCheck = pMsgBoardQuery; pCheck; pCheck = pCheck->pNext)
1272  pCheck->CallbackObj.DenumeratePointers();
1273 }
1274 
1276 {
1277  C4Object *pCrew;
1278 
1279  // Remove all crew objects
1280  while ((pCrew = Crew.GetObject())) pCrew->AssignRemoval(true);
1281 }
1282 
1283 int32_t C4Player::FindNewOwner() const
1284 {
1285  int32_t iNewOwner = NO_OWNER;
1286  C4Team *pTeam;
1287  if (Team) if ((pTeam = Game.Teams.GetTeamByID(Team)))
1288  {
1289  for (int32_t i=0; i<pTeam->GetPlayerCount(); ++i)
1290  {
1291  int32_t iPlrID = pTeam->GetIndexedPlayer(i);
1292  if (iPlrID && iPlrID != ID)
1293  {
1294  C4PlayerInfo *pPlrInfo = Game.PlayerInfos.GetPlayerInfoByID(iPlrID);
1295  if (pPlrInfo) if (pPlrInfo->IsJoined())
1296  {
1297  // this looks like a good new owner
1298  iNewOwner = pPlrInfo->GetInGameNumber();
1299  break;
1300  }
1301  }
1302  }
1303  }
1304  // if noone from the same team was found, try to find another non-hostile player
1305  // (necessary for cooperative rounds without teams)
1306  if (iNewOwner == NO_OWNER)
1307  for (C4Player *pOtherPlr = ::Players.First; pOtherPlr; pOtherPlr = pOtherPlr->Next)
1308  if (pOtherPlr != this) if (!pOtherPlr->Eliminated)
1309  if (!::Players.Hostile(pOtherPlr->Number, Number))
1310  iNewOwner = pOtherPlr->Number;
1311 
1312  return iNewOwner;
1313 }
1314 
1316 {
1317  int32_t iNewOwner = FindNewOwner();
1318  // notify objects in all object lists
1319  for (C4ObjectList *pList = &::Objects; pList; pList = ((pList == &::Objects) ? &::Objects.InactiveObjects : nullptr))
1320  {
1321  for (C4Object *cobj : *pList)
1322  {
1323  if (cobj->Status && cobj->Owner == Number)
1324  {
1325  C4AulFunc *pFn = cobj->GetFunc(PSF_OnOwnerRemoved);
1326  if (pFn)
1327  {
1328  C4AulParSet pars(iNewOwner);
1329  pFn->Exec(cobj, &pars);
1330  }
1331  else
1332  {
1333  // crew members: Those are removed later (AFTER the player has been removed, for backwards compatiblity with relaunch scripting)
1334  if (Crew.IsContained(cobj))
1335  continue;
1336  // Regular objects: Try to find a new, suitable owner from the same team
1337  // Ignore StaticBack, because this would not be compatible with many internal objects such as team account
1338  if ((cobj->Category & C4D_StaticBack) == 0)
1339  cobj->SetOwner(iNewOwner);
1340  }
1341  }
1342  }
1343  }
1344 }
1345 
1346 bool C4Player::DoScore(int32_t iChange)
1347 {
1348  CurrentScore = Clamp<int32_t>( CurrentScore+iChange, -100000, 100000 );
1349  return true;
1350 }
1351 
1352 void C4Player::SetCursor(C4Object *pObj, bool fSelectArrow)
1353 {
1354  // check disabled
1355  if (pObj) if (pObj->CrewDisabled) return;
1356  bool fChanged = pObj != Cursor;
1357  C4Object *pPrev = Cursor;
1358  // Set cursor
1359  Cursor=pObj;
1360  // unselect previous
1361  if (pPrev && fChanged) pPrev->UnSelect();
1362  // Select object
1363  if (fChanged && Cursor) { Cursor->DoSelect(); }
1364  // View flash
1365  if (fSelectArrow) CursorFlash=30;
1366 }
1367 
1368 void C4Player::ScrollView(float iX, float iY, float ViewWdt, float ViewHgt)
1369 {
1370  if (ViewLock) return;
1372  float ViewportScrollBorder = Application.isEditor ? 0 : C4ViewportScrollBorder;
1373  ViewX = Clamp<C4Real>( ViewX+ftofix(iX), ftofix(ViewWdt/2.0f-ViewportScrollBorder), ftofix(::Landscape.GetWidth()+ViewportScrollBorder-ViewWdt/2.0f) );
1374  ViewY = Clamp<C4Real>( ViewY+ftofix(iY), ftofix(ViewHgt/2.0f-ViewportScrollBorder), ftofix(::Landscape.GetHeight()+ViewportScrollBorder-ViewHgt/2.0f) );
1375 }
1376 
1378 {
1379  // Mark any control set as unused
1380  Control.Clear();
1381  // Reset control
1382  LocalControl = false;
1384  ControlSet=nullptr;
1385  MouseControl = false;
1386  if (pGamepad)
1387  {
1388  pGamepad->SetPlayer(NO_OWNER);
1389  pGamepad.reset();
1390  }
1391  // no controls issued yet
1392  ControlCount = ActionCount = 0;
1394  LastControlID = 0;
1395 }
1396 
1398 {
1399  // Check local control
1400  if (AtClient == ::Control.ClientID())
1401  if (!GetInfo() || GetInfo()->GetType() == C4PT_User)
1402  if (!::Control.isReplay())
1403  LocalControl=true;
1404  // needs to init control for local players only
1405  if (LocalControl)
1406  {
1407  // Preferred control
1410  // control set unassigned/not known? fallback to some default then (=first defined control set)
1412  // gamepad control safety (assuming the default control set is not using gamepad)
1414  {
1416  }
1417  // Choose next while control taken
1418  // TODO
1419  // init gamepad
1420  if (ControlSet && ControlSet->HasGamepad())
1421  {
1422  if (!FindGamepad())
1423  {
1424  LogF("No gamepad available for %s, please plug one in!", Name.getData());
1425  ::Game.Pause();
1426  }
1427  }
1428  // Mouse
1429  if (ControlSet && ControlSet->HasMouse() && PrefMouse)
1430  if (!::Players.MouseControlTaken())
1431  MouseControl=true;
1432  // Some controls such as gamepad control need special synced GUI elements
1433  // Do a script callback for selected control
1435  }
1436  // clear old control method and register new
1438 }
1439 
1440 bool C4Player::FindGamepad()
1441 {
1443  if (!newPad) return false;
1444  newPad->SetPlayer(ID);
1445  // Release the old gamepad.
1446  if (pGamepad) pGamepad->SetPlayer(NO_OWNER);
1447  pGamepad = newPad;
1448  LogF("%s: Using gamepad #%d.", Name.getData(), pGamepad->GetID());
1449  return true;
1450 }
1451 
1453 
1454 int VisibilityCheck(int iVis, int sx, int sy, int cx, int cy)
1455 {
1456  sx -= igOffX; sy -= igOffY; cx -= igOffX; cy -= igOffY;
1457  int st = std::max(1, std::max(Abs(sx - cx), Abs(sy - cy)));
1458  for (int i = 0; i <= st; i++)
1459  {
1460  int x = (sx * (st - i) + cx * i) / st, y = (sy * (st - i) + cy * i) / st;
1461  if (GBackSolid(x, y))
1462  {
1463  if ((iVis -= 2) <= 0)
1464  return 0;
1465  }
1466  }
1467  return iVis;
1468 }
1469 
1471 {
1472  // cancel all player menus
1473  Menu.Close(false);
1474 }
1475 
1477 {
1478  if (Eliminated) return;
1479  Eliminated=true;
1481  StartSoundEffect("UI::Eliminated");
1482  Log(FormatString(LoadResStr("IDS_PRC_PLRELIMINATED"),GetName()).getData());
1483 
1484  // Early client deactivation check
1485  if (::Control.isCtrlHost() && AtClient > C4ClientIDHost && !::Application.isEditor)
1486  {
1487  // Check: Any player left at this client?
1488  C4Player *pPlr = nullptr;
1489  for (int i = 0; (pPlr = ::Players.GetAtClient(AtClient, i)); i++)
1490  if (!pPlr->Eliminated)
1491  break;
1492  // If not, deactivate the client
1493  if (!pPlr)
1494  ::Control.DoInput(CID_ClientUpdate,
1496  CDT_Sync);
1497  }
1498 }
1499 
1501 {
1502  // get number of objects in crew that is not disabled
1503  int32_t iNum=0;
1504  for (C4Object *cObj : Crew)
1505  if (cObj)
1506  if (!cObj->CrewDisabled)
1507  ++iNum;
1508  // return it
1509  return iNum;
1510 }
1511 
1513 {
1514  if (Cursor && !Cursor->CrewDisabled)
1515  return 1;
1516  return 0;
1517 }
1518 
1519 void C4Player::EvaluateLeague(bool fDisconnected, bool fWon)
1520 {
1521  // already evaluated?
1522  if (LeagueEvaluated) return; LeagueEvaluated=true;
1523  // set fate
1524  C4PlayerInfo *pInfo = GetInfo();
1525  if (pInfo)
1526  {
1527  if (fDisconnected)
1528  pInfo->SetDisconnected();
1529  if (fWon)
1530  pInfo->SetWinner();
1531  }
1532 }
1533 
1535 {
1536  // local sync not necessary for script players
1537  if (GetType() == C4PT_Script) return true;
1538  // evaluate total playing time
1541  // evaluate total playing time of all the crew
1542  for (C4ObjectInfo *pInf = CrewInfoList.GetFirst(); pInf; pInf=pInf->Next)
1543  if (pInf->InAction)
1544  {
1545  pInf->TotalPlayingTime+=(Game.Time-pInf->InActionTime);
1546  pInf->InActionTime = Game.Time;
1547  }
1548  // save player
1549  if (!Save())
1550  return false;
1551  // done, success
1552  return true;
1553 }
1554 
1556 {
1558 }
1559 
1560 bool C4Player::SetObjectCrewStatus(C4Object *pCrew, bool fNewStatus)
1561 {
1562  // either add...
1563  if (fNewStatus)
1564  {
1565  // is in crew already?
1566  if (Crew.IsContained(pCrew)) return true;
1567  return MakeCrewMember(pCrew, false);
1568  }
1569  else
1570  {
1571  // already outside?
1572  if (!Crew.IsContained(pCrew)) return true;
1573  // ...or remove
1574  Crew.Remove(pCrew);
1575  C4AulParSet parset(Number);
1576  pCrew->Call(PSF_OnRemoveCrew, &parset);
1577  // remove info, if assigned to this player
1578  // theoretically, info objects could remain when the player is deleted
1579  // but then they would be reassigned to the player crew when loaded in a savegame
1580  // by the crew-assignment code kept for backwards compatibility with pre-4.95.2-savegames
1581  if (pCrew->Info && CrewInfoList.IsElement(pCrew->Info))
1582  {
1583  pCrew->Info->Retire();
1584  pCrew->Info = nullptr;
1585  }
1586  }
1587  // done, success
1588  return true;
1589 }
1590 
1592 {
1593  // del prev
1594  ClearGraphs();
1595  // create graphs
1597  {
1598  DWORD dwGraphClr = ColorDw;
1599  C4PlayerInfo *pInfo;
1600  if (ID && (pInfo = Game.PlayerInfos.GetPlayerInfoByID(ID)))
1601  {
1602  // set color by player info class
1603  dwGraphClr = pInfo->GetColor();
1604  }
1605  C4GUI::MakeColorReadableOnBlack(dwGraphClr); dwGraphClr &= 0xffffff;
1607  pstatControls->SetColorDw(dwGraphClr);
1610  pstatActions->SetColorDw(dwGraphClr);
1612  // register into
1613  Game.pNetworkStatistics->statControls.AddGraph(pstatControls);
1614  Game.pNetworkStatistics->statActions.AddGraph(pstatActions);
1615  }
1616 }
1617 
1619 {
1620  // del all assigned graphs
1621  if (pstatControls)
1622  {
1623  if (Game.pNetworkStatistics) Game.pNetworkStatistics->statControls.RemoveGraph(pstatControls);
1624  delete pstatControls;
1625  pstatControls = nullptr;
1626  }
1627  if (pstatActions)
1628  {
1629  if (Game.pNetworkStatistics) Game.pNetworkStatistics->statActions.RemoveGraph(pstatActions);
1630  delete pstatActions;
1631  pstatActions = nullptr;
1632  }
1633 }
1634 
1635 void C4Player::CountControl(ControlType eType, int32_t iID, int32_t iCntAdd)
1636 {
1637  // count it
1638  ControlCount += iCntAdd;
1639  // catch doubles
1640  if (eType == LastControlType && iID == LastControlID) return;
1641  // no double: count as action
1642  LastControlType = eType;
1643  LastControlID = iID;
1644  ActionCount += iCntAdd;
1645  // and give experience
1646  if (Cursor && Cursor->Info)
1647  {
1648  if (Cursor->Info)
1649  {
1650  Cursor->Info->ControlCount++; if ((Cursor->Info->ControlCount%5) == 0) Cursor->DoExperience(+1);
1651  }
1652  }
1653 }
1654 
1655 void C4Player::ExecMsgBoardQueries()
1656 {
1657  // already active?
1658  if (::MessageInput.IsTypeIn()) return;
1659  // find an un-evaluated query
1661  while (pCheck) if (!pCheck->fAnswered) break; else pCheck = pCheck->pNext;
1662  if (!pCheck) return;
1663  // open it
1664  ::MessageInput.StartTypeIn(true, pCheck->CallbackObj, pCheck->fIsUppercase, false, Number, pCheck->sInputQuery);
1665 }
1666 
1667 void C4Player::CallMessageBoard(C4Object *pForObj, const StdStrBuf &sQueryString, bool fIsUppercase)
1668 {
1669  // remove any previous query for the same object
1670  RemoveMessageBoardQuery(pForObj);
1671  // sort new query to end of list
1672  C4MessageBoardQuery **ppTarget = &pMsgBoardQuery;
1673  while (*ppTarget) ppTarget = &((*ppTarget)->pNext);
1674  *ppTarget = new C4MessageBoardQuery(pForObj, sQueryString, fIsUppercase);
1675 }
1676 
1678 {
1679  // get matching query
1680  C4MessageBoardQuery **ppCheck = &pMsgBoardQuery, *pFound;
1681  while (*ppCheck) if ((*ppCheck)->CallbackObj == pForObj) break; else ppCheck = &((*ppCheck)->pNext);
1682  pFound = *ppCheck;
1683  if (!pFound) return false;
1684  // remove it
1685  *ppCheck = (*ppCheck)->pNext;
1686  delete pFound;
1687  return true;
1688 }
1689 
1691 {
1692  // get matching query
1694  while (pCheck) if (pCheck->CallbackObj == pForObj && !pCheck->fAnswered) break; else pCheck = pCheck->pNext;
1695  if (!pCheck) return false;
1696  // mark it
1697  pCheck->fAnswered = true;
1698  return true;
1699 }
1700 
1702 {
1703  // return whether any object has a messageboard-query
1704  return !!pMsgBoardQuery;
1705 }
1706 
1708 {
1709  // looks like a selected team was not available: Go back to team selection if this is not a mislead call
1712 }
1713 
1714 void C4Player::SetPlayerColor(uint32_t dwNewClr)
1715 {
1716  // no change?
1717  if (dwNewClr == ColorDw) return;
1718  // reflect change in all active, player-owned objects
1719  // this can never catch everything (thinking of overlays, etc.); scenarios that allow team changes should take care of the rest
1720  uint32_t dwOldClr = ColorDw;
1721  ColorDw = dwNewClr;
1722  for (C4Object *pObj : Objects)
1723  if (pObj && pObj->Status && pObj->Owner == Number)
1724  {
1725  if ((pObj->Color & 0xffffff) == (dwOldClr & 0xffffff))
1726  pObj->Color = (pObj->Color & 0xff000000u) | (dwNewClr & 0xffffff);
1727  }
1728 }
1729 
1731 {
1732  // type by info
1734  if (pInfo) return pInfo->GetType(); else { assert(false); return C4PT_User; }
1735 }
1736 
1738 {
1739  // invisible by info
1741  if (pInfo) return pInfo->IsInvisible(); else { assert(false); return false; }
1742 }
1743 
1745 {
1746  // Activate mouse control if it's available
1747  if (!MouseControl && !::Players.MouseControlTaken())
1748  {
1749  ::MouseControl.Init(Number);
1750  MouseControl=true;
1751  }
1752  // Deactivate mouse control
1753  else if (MouseControl)
1754  {
1755  ::MouseControl.Clear();
1756  ::MouseControl.Default();
1757  MouseControl = 0;
1758  // Scrolling isn't possible any more
1759  if (ViewMode == C4PVM_Scrolling)
1761  }
1762 }
1763 
1765 {
1766  // Not during game over dialog
1767  if (C4GameOverDlg::IsShown()) return false;
1768  // Open menu
1769  return !!Menu.ActivateMain(Number);
1770 }
1771 
1773 {
1774  int entries = size();
1775  if (pComp->isDeserializer())
1776  {
1777  clear();
1778  pComp->Value(entries);
1779  while (entries--)
1780  {
1781  int number;
1782  pComp->Value(number);
1783  assert(::Players.Valid(number));
1784  C4Player *plr = ::Players.Get(number);
1785  if (plr)
1786  insert(plr);
1787  }
1788  }
1789  else
1790  {
1791  pComp->Value(entries);
1792  for (const_iterator it = begin(); it != end(); ++it)
1793  {
1794  int32_t num = (*it)->Number;
1795  pComp->Value(num); // Can't use (*it)->Number directly because StdCompiler is dumb about constness
1796  }
1797  }
1798 }
1799 
1800 void C4Player::SetZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool direct, bool no_increase, bool no_decrease)
1801 {
1802  AdjustZoomParameter(&ZoomWdt, range_wdt, no_increase, no_decrease);
1803  AdjustZoomParameter(&ZoomHgt, range_hgt, no_increase, no_decrease);
1804  ZoomToViewports(direct, no_decrease, no_increase); // inc/dec swapped for zoom, because it's inversely proportional to range
1805 }
1806 
1807 void C4Player::SetMinZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease)
1808 {
1809  AdjustZoomParameter(&ZoomLimitMinWdt, range_wdt, no_increase, no_decrease);
1810  AdjustZoomParameter(&ZoomLimitMinHgt, range_hgt, no_increase, no_decrease);
1812 }
1813 
1814 void C4Player::SetMaxZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease)
1815 {
1816  AdjustZoomParameter(&ZoomLimitMaxWdt, range_wdt, no_increase, no_decrease);
1817  AdjustZoomParameter(&ZoomLimitMaxHgt, range_hgt, no_increase, no_decrease);
1819 }
1820 
1821 void C4Player::SetZoom(C4Fixed zoom, bool direct, bool no_increase, bool no_decrease)
1822 {
1823  AdjustZoomParameter(&ZoomVal, zoom, no_increase, no_decrease);
1824  ZoomToViewports(direct, no_increase, no_decrease);
1825 }
1826 
1827 void C4Player::SetMinZoom(C4Fixed zoom, bool no_increase, bool no_decrease)
1828 {
1829  AdjustZoomParameter(&ZoomLimitMinVal, zoom, no_increase, no_decrease);
1831 }
1832 
1833 void C4Player::SetMaxZoom(C4Fixed zoom, bool no_increase, bool no_decrease)
1834 {
1835  AdjustZoomParameter(&ZoomLimitMaxVal, zoom, no_increase, no_decrease);
1837 }
1838 
1839 void C4Player::ZoomToViewports(bool direct, bool no_increase, bool no_decrease)
1840 {
1841  C4Viewport *vp = nullptr;
1842  while((vp = ::Viewports.GetViewport(Number, vp)) != nullptr)
1843  ZoomToViewport(vp, direct, no_increase, no_decrease);
1844 }
1845 
1846 void C4Player::ZoomToViewport(C4Viewport* vp, bool direct, bool no_increase, bool no_decrease)
1847 {
1848  float new_zoom = ZoomVal ? fixtof(ZoomVal) : vp->GetZoomByViewRange((ZoomWdt || ZoomHgt) ? ZoomWdt : C4VP_DefViewRangeX,ZoomHgt);
1849  float old_zoom = vp->GetZoomTarget();
1850  if (new_zoom > old_zoom && no_increase) return;
1851  if (new_zoom < old_zoom && no_decrease) return;
1852  vp->SetZoom(new_zoom, direct);
1853 }
1854 
1856 {
1857  C4Viewport *vp = nullptr;
1858  while((vp = ::Viewports.GetViewport(Number, vp)) != nullptr)
1860 }
1861 
1863 {
1866  vp->SetZoomLimits(zoom_min, zoom_max);
1867 }
1868 
1869 bool C4Player::AdjustZoomParameter(int32_t *range_par, int32_t new_val, bool no_increase, bool no_decrease)
1870 {
1871  // helper function: Adjust *range_par to new_val if increase/decrease not forbidden
1872  if (new_val < *range_par)
1873  {
1874  if (!no_decrease) *range_par = new_val;
1875  return !no_decrease;
1876  }
1877  else if(new_val > *range_par)
1878  {
1879  if (!no_increase) *range_par = new_val;
1880  return !no_increase;
1881  }
1882  return true;
1883 }
1884 
1885 bool C4Player::AdjustZoomParameter(C4Fixed *zoom_par, C4Fixed new_val, bool no_increase, bool no_decrease)
1886 {
1887  // helper function: Adjust *zoom_par to new_val if increase/decrease not forbidden
1888  if (new_val < *zoom_par)
1889  {
1890  if (!no_decrease) *zoom_par = new_val;
1891  return !no_decrease;
1892  }
1893  else if(new_val > *zoom_par)
1894  {
1895  if (!no_increase) *zoom_par = new_val;
1896  return !no_increase;
1897  }
1898  return true;
1899 }
1900 
1901 void C4Player::SetViewLocked(bool to_val)
1902 {
1903  if ((ViewLock = to_val))
1904  {
1905  // view was locked - cancel any scrolling
1907  }
1908 }
1909 
1910 bool C4Player::GainScenarioAchievement(const char *achievement_id, int32_t value, const char *scen_name_override)
1911 {
1912  // Determine full ID of achievement
1913  if (!scen_name_override)
1914  {
1915  if (::Game.C4S.Head.Origin.getLength())
1916  scen_name_override = ::Game.C4S.Head.Origin.getData();
1917  else
1918  scen_name_override = ::Game.ScenarioFilename;
1919  }
1920  StdStrBuf sAchvID = C4ScenarioParameters::AddFilename2ID(scen_name_override, achievement_id);
1921  // Gain achievement iff it's an improvement
1922  Achievements.SetValue(sAchvID.getData(), value, true);
1923  return true;
1924 }
1925 
1927 {
1928  // set modifier to be applied to all new sounds being played in a player's viewport
1929  // update prop list parameter
1930  C4SoundModifier *mod;
1931  if (new_modifier)
1932  {
1933  SoundModifier.SetPropList(new_modifier);
1934  mod = ::Application.SoundSystem.Modifiers.Get(new_modifier, true);
1935  }
1936  else
1937  {
1938  SoundModifier.Set0();
1939  mod = nullptr;
1940  }
1941  // update in sound system
1943 }
bool IsHostileTowards(const C4Player *opponent) const
Definition: C4Player.cpp:864
const int C4RetireDelay
Definition: C4Constants.h:29
const int32_t C4PVM_Scrolling
Definition: C4Player.h:35
const char * getData() const
Definition: StdBuf.h:450
C4SoundSystem SoundSystem
Definition: C4Application.h:42
#define PSF_OnOwnerRemoved
Definition: C4GameScript.h:146
int32_t GetPlayerCount() const
Definition: C4Teams.h:64
bool FindEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr)
Definition: C4Group.cpp:1774
int32_t GetY() const
Definition: C4Object.h:287
class C4PlayerInfo * GetInfo()
Definition: C4Player.cpp:1555
void SetFoW(bool fEnable)
Definition: C4Player.cpp:727
#define PSF_OnRemoveCrew
Definition: C4GameScript.h:94
C4IDList BuildKnowledge
Definition: C4Scenario.h:149
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const
Definition: stub-handle.cpp:67
bool DoSelect()
Definition: C4Object.cpp:4324
StdCopyStrBuf Origin
Definition: C4Scenario.h:80
int32_t TotalScore
Definition: C4InfoCore.h:72
void CloseMenu()
Definition: C4Player.cpp:1470
void SetName(const char *NewName=0)
Definition: C4Object.cpp:1694
void RecheckPlayerSort(C4Player *pForPlayer)
int32_t TotalPlayingTime
Definition: C4InfoCore.h:92
int32_t GetID() const
Definition: C4Teams.h:66
int32_t MouseControl
Definition: C4Player.h:94
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:104
C4Object * CreateObjectConstruction(C4PropList *type, C4Object *pCreator, int32_t owner, int32_t ctx=0, int32_t bty=0, int32_t con=1, bool terrain=false)
Definition: C4Game.cpp:1106
C4Config Config
Definition: C4Config.cpp:831
bool ConsolidateValids(C4DefList &rDefs, int32_t dwCategory=0)
Definition: C4IDList.cpp:367
const char * GetName() const
Definition: C4PlayerInfo.h:160
void SetDisconnected()
Definition: C4PlayerInfo.h:203
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1275
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
const size_t C4MaxTitle
Definition: C4Constants.h:25
char AtClientName[C4MaxTitle+1]
Definition: C4Player.h:100
C4ID id
Definition: C4Object.h:108
int32_t LastControlID
Definition: C4Player.h:150
int32_t EnforcePosition
Definition: C4Scenario.h:144
int32_t Team
Definition: C4Player.h:90
C4ObjectPtr Cursor
Definition: C4Player.h:132
int32_t ProductionDelay
Definition: C4Player.h:124
bool Refill()
Definition: C4Menu.cpp:918
uint32_t Random()
Definition: C4Random.cpp:43
C4PlayerControlAssignmentSet * GetDefaultSet()
int32_t Won
Definition: C4InfoCore.h:71
virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted=nullptr)
int32_t Load(C4Group &hGroup)
C4PlayerControlAssignmentSet * GetSetByName(const char *szName)
int32_t Score
Definition: C4InfoCore.h:72
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1012
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
C4MainMenu Menu
Definition: C4Player.h:105
bool HasMessageBoardQuery()
Definition: C4Player.cpp:1701
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
void CheckCrewExPromotion()
Definition: C4Player.cpp:909
bool ViewLock
Definition: C4Player.h:109
int32_t ViewMode
Definition: C4Player.h:107
int32_t ControlCount
Definition: C4Player.h:148
bool IsMelee()
Definition: C4Scenario.cpp:510
C4Game Game
Definition: C4Globals.cpp:52
bool DenumeratePointers()
int32_t Number
Definition: C4Player.h:88
#define PSF_OnJoinCrew
Definition: C4GameScript.h:93
int32_t RoundsWon
Definition: C4InfoCore.h:91
C4Object * GetFirstObject() const
Definition: C4ObjectList.h:141
int32_t iTick35
Definition: C4Game.h:131
C4Scenario C4S
Definition: C4Game.h:76
int32_t FlashCom
Definition: C4Player.h:112
C4IDList BaseProduction
Definition: C4Scenario.h:151
int AverageScoreGain() const
void Clear()
Definition: StdBuf.h:474
C4ConfigGeneral General
Definition: C4Config.h:252
void ZoomLimitsToViewport(C4Viewport *vp)
Definition: C4Player.cpp:1862
C4Player()
Definition: C4Player.cpp:49
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:78
Definition: C4Teams.h:30
const char * GetData() const
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:105
bool CreateContentsByList(C4IDList &idlist)
Definition: C4Object.cpp:1459
bool IsInvisible() const
Definition: C4Player.cpp:1737
int32_t ActiveCrewCount()
Definition: C4Player.cpp:1500
class C4TableGraph * pstatActions
Definition: C4Player.h:147
C4IDList ReadyCrew
Definition: C4Scenario.h:145
C4ComponentHost GameText
Definition: C4Game.h:81
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
char Filename[_MAX_PATH+1]
Definition: C4Player.h:82
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:333
void OnPlayerJoinFinished()
Definition: C4Game.cpp:3084
C4SLandscape Landscape
Definition: C4Scenario.h:234
int32_t ControlCount
Definition: C4ObjectInfo.h:38
void Eliminate()
Definition: C4Player.cpp:1476
int32_t ObjectsOwned
Definition: C4Player.h:119
void ToggleMouseControl()
Definition: C4Player.cpp:1744
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *)
Definition: C4Player.cpp:1078
void ClearControl()
Definition: C4Player.cpp:1377
bool ShowStartup
Definition: C4Player.h:111
C4Team * GetGenerateTeamByID(int32_t iID)
Definition: C4Teams.cpp:391
int VisibilityCheck(int iVis, int sx, int sy, int cx, int cy)
Definition: C4Player.cpp:1454
void UpdateView()
Definition: C4Player.cpp:1184
StdCopyStrBuf PrefControl
Definition: C4InfoCore.h:97
bool ScenarioAndTeamInit(int32_t idTeam)
Definition: C4Player.cpp:120
C4PlayerInfo * GetPlayerInfoByIndex(int32_t index) const
ControlType LastControlType
Definition: C4Player.h:150
bool IsInvisible() const
Definition: C4PlayerInfo.h:178
void Close(bool fOK)
bool Load(const char *szFilename, bool fSavegame)
Definition: C4Player.cpp:941
C4ObjectInfo * Next
Definition: C4ObjectInfo.h:41
std::shared_ptr< C4GamePadOpener > GetAvailableGamePad()
int32_t ZoomLimitMinHgt
Definition: C4Player.h:114
void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0)
Definition: C4Facet.cpp:213
bool IsNoEliminationCheck() const
Definition: C4PlayerInfo.h:182
DWORD MakeColorReadableOnBlack(DWORD &rdwClr)
Definition: C4Gui.cpp:99
C4Player * First
Definition: C4PlayerList.h:31
void Set0()
Definition: C4Value.h:336
virtual void Default()
Definition: C4MainMenu.cpp:44
bool Hostile(int iPlayer1, int iPlayer2) const
const int C4S_MaxPlayer
Definition: C4Constants.h:53
const int C4ViewportScrollBorder
Definition: C4Constants.h:65
C4MessageInput MessageInput
int32_t GetSelectedCrewCount()
Definition: C4Player.cpp:1512
C4ObjectPtr CallbackObj
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
C4PlayerControl Control
Definition: C4Player.h:131
bool GamepadEnabled
Definition: C4Config.h:59
int32_t PlrStartIndex
Definition: C4Player.h:96
bool Delete(const char *szFiles, bool fRecursive=false)
Definition: C4Group.cpp:1334
#define toC4CStr(szString)
Definition: StdAdaptors.h:25
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
#define _MAX_PATH
int32_t Position
Definition: C4Player.h:95
C4SoundModifier * Get(class C4PropList *props, bool create_if_not_found)
void SetCursor(C4Object *pObj, bool fSelectArrow)
Definition: C4Player.cpp:1352
size_t SLen(const char *sptr)
Definition: Standard.h:78
void SetZoom(C4Fixed zoom, bool direct, bool no_increase, bool no_decrease)
Definition: C4Player.cpp:1821
void ZoomLimitsToViewports()
Definition: C4Player.cpp:1855
int32_t ProductionUnit
Definition: C4Player.h:124
void DrawHostility(C4Facet &cgo, int32_t iIndex)
Definition: C4Player.cpp:999
C4GraphicsResource GraphicsResource
int igOffX
Definition: C4Player.cpp:1452
C4GameParameters & Parameters
Definition: C4Game.h:69
StdStrBuf Name
Definition: C4Player.h:83
void ZoomToViewport(C4Viewport *vp, bool direct, bool no_increase=false, bool no_decrease=false)
Definition: C4Player.cpp:1846
int32_t ZoomLimitMaxWdt
Definition: C4Player.h:114
void ClearPointers(C4Object *tptr, bool fDeath)
Definition: C4Player.cpp:100
void DenumeratePointers()
Definition: C4Player.cpp:1262
C4Player * GetAtClient(int iClient, int iIndex=0) const
bool Promote(int32_t torank, bool exception, bool fForceRankName)
Definition: C4Object.cpp:1727
char MessageBuf[256+1]
Definition: C4Player.h:137
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
C4TeamList & Teams
Definition: C4Game.h:72
bool ActivateMenuTeamSelection(bool fFromMain)
Definition: C4Player.cpp:1242
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:46
int32_t PrefMouse
Definition: C4InfoCore.h:98
C4ObjectInfo * GetFirst()
C4ObjectInfo * Info
Definition: C4Object.h:145
std::shared_ptr< class C4GamePadOpener > pGamepad
Definition: C4Player.h:134
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int32_t RoundsLost
Definition: C4InfoCore.h:91
Definition: C4Real.h:58
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:46
bool Pause()
Definition: C4Game.cpp:954
bool FinalInit(bool fInitialScore)
Definition: C4Player.cpp:703
const int32_t FullCon
Definition: C4Constants.h:182
void Default()
Definition: C4FacetEx.h:43
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
uint32_t ColorDw
Definition: C4Player.h:91
static StdStrBuf AddFilename2ID(const char *filename, const char *id)
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
C4ObjectList InactiveObjects
Definition: C4GameObjects.h:43
const C4ObjectLink * GetLink(const C4Object *pObj) const
int32_t CursorFlash
Definition: C4Player.h:133
void CallMessageBoard(C4Object *pForObj, const StdStrBuf &sQueryString, bool fUppercase)
Definition: C4Player.cpp:1667
static const C4ObjectPtr Null
Definition: C4ObjectPtr.h:28
int32_t Wdt
Definition: C4Rect.h:32
bool StartTypeIn(bool fObjInput=false, C4Object *pObj=nullptr, bool fUpperCase=false, bool fTeam=false, int32_t iPlr=-1, const StdStrBuf &rsInputQuery=StdStrBuf())
C4Player * Get(int iPlayer) const
int32_t ZoomWdt
Definition: C4Player.h:114
void OnTeamSelectionFailed()
Definition: C4Player.cpp:1707
bool SaveGame
Definition: C4Scenario.h:71
int32_t FrameCounter
Definition: C4Game.h:130
const int32_t C4P_Number_None
Definition: C4Player.h:37
class C4PlayerControlAssignmentSet * ControlSet
Definition: C4Player.h:92
static bool Strip(const char *szFilename, bool fAggressive)
Definition: C4Player.cpp:961
~C4Player()
Definition: C4Player.cpp:78
void Default()
Definition: stub-handle.cpp:63
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:253
bool LoadRuntimeData(C4Group &hGroup, C4ValueNumbers *)
Definition: C4Player.cpp:1136
C4Shape Shape
Definition: C4Def.h:106
C4SoundModifierList Modifiers
Definition: C4SoundSystem.h:54
C4SVal MapZoom
Definition: C4Scenario.h:176
C4Network2 Network
Definition: C4Globals.cpp:53
C4Def * Def
Definition: C4Object.h:143
bool Message(const char *szMsg)
Definition: C4Player.cpp:933
void SetZoomLimits(float to_min_zoom, float to_max_zoom)
Definition: C4Viewport.cpp:459
bool CrewDisabled
Definition: C4Object.h:163
C4Player * GetByIndex(int iIndex) const
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t hrange)
void NotifyOwnedObjects()
Definition: C4Player.cpp:1315
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:81
void ScrollView(float iX, float iY, float ViewWdt, float ViewHgt)
Definition: C4Player.cpp:1368
float GetZoomTarget() const
Definition: C4Viewport.h:58
bool IncreaseIDCount(C4ID c_id, bool fAddNewID=true, int32_t IncreaseBy=1, bool fRemoveEmpty=false)
Definition: C4IDList.cpp:220
uint32_t Date
Definition: C4InfoCore.h:69
bool GameOver
Definition: C4Game.h:116
int32_t Status
Definition: C4Player.h:84
C4Object * GetHiRankActiveCrew()
Definition: C4Player.cpp:890
ControlType
Definition: C4Player.h:60
bool Valid(int iPlayer) const
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
void CreateGraphs()
Definition: C4Player.cpp:1591
C4IDList Knowledge
Definition: C4Player.h:129
C4SVal Wealth
Definition: C4Scenario.h:142
int32_t lightRange
Definition: C4Object.h:122
void SetZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool direct, bool no_increase, bool no_decrease)
Definition: C4Player.cpp:1800
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:586
int32_t FindNewOwner() const
Definition: C4Player.cpp:1283
int32_t GetForcedTeamSelection(int32_t idForPlayer) const
Definition: C4Teams.cpp:851
C4Landscape Landscape
void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false)
Definition: C4Player.cpp:771
bool Save(C4Group &hGroup)
Definition: C4InfoCore.cpp:110
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
bool IsJoined() const
Definition: C4PlayerInfo.h:169
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
void SetZoom(float zoomValue)
Definition: C4Viewport.cpp:495
C4ID GetScriptPlayerExtraID() const
Definition: C4PlayerInfo.h:181
void AddPlayer(class C4PlayerInfo &rInfo, bool fAdjustPlayer)
Definition: C4Teams.cpp:53
void Execute()
Definition: C4Player.cpp:164
C4FacetSurface BigIcon
Definition: C4Player.h:140
C4Group ScenarioFile
Definition: C4Game.h:88
static bool IsShown()
Definition: C4GameOverDlg.h:92
C4PlayerList Players
bool C4Group_CopyItem(const char *szSource, const char *szTarget1, bool fNoSort, bool fResetAttributes)
Definition: C4Group.cpp:100
int32_t Time
Definition: C4Game.h:133
int32_t GetTeam() const
Definition: C4PlayerInfo.h:198
void ClearPointers(C4Object *pObj)
Definition: C4Menu.cpp:1161
int32_t GetPlrStartIndex() const
Definition: C4Teams.h:69
void RegisterKeyset(int32_t iPlr, C4PlayerControlAssignmentSet *pKeyset)
class C4TableGraph * pstatControls
Definition: C4Player.h:147
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
int32_t GetX() const
Definition: C4Object.h:286
C4Network2Res::Ref Derive()
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:257
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars=0, bool fPassError=false, bool fRejectTest=false)
Definition: C4Game.cpp:3850
void SetPlayerColor(uint32_t dwNewClr)
Definition: C4Player.cpp:1714
Definition: C4Def.h:100
const int NO_OWNER
Definition: C4Constants.h:138
void SetMaxZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease)
Definition: C4Player.cpp:1814
bool Close()
Definition: C4Group.cpp:755
bool SetObjectCrewStatus(C4Object *pCrew, bool fNewStatus)
Definition: C4Player.cpp:1560
bool DoWealth(int32_t change)
Definition: C4Player.cpp:733
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:73
C4Object * GetHiExpActiveCrew()
Definition: C4Player.cpp:871
char Name[C4MaxName+1]
Definition: C4InfoCore.h:38
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:69
C4Object * GetObject(int Index=0) const
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
int32_t MessageStatus
Definition: C4Player.h:136
int32_t Status
Definition: C4PropList.h:169
void SetViewLocked(bool to_val)
Definition: C4Player.cpp:1901
void SetCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr)
Definition: C4Object.cpp:2610
bool SetKnowledge(C4ID id, bool fRemove)
Definition: C4Player.cpp:756
const int32_t C4D_StaticBack
Definition: C4Def.h:42
C4Network2Res::Ref getRefRes(int32_t iResID)
int32_t GameJoinTime
Definition: C4Player.h:98
void Value(const T &rStruct)
Definition: StdCompiler.h:171
static C4ControlPlayerAction * InitScenarioPlayer(const C4Player *source, int32_t team)
Definition: C4Control.cpp:615
C4Fixed ftofix(float x)
Definition: C4Real.h:258
void AdjustPosition(bool immediate=false)
Definition: C4Viewport.cpp:544
bool Evaluated
Definition: C4Player.h:87
Definition: C4Id.h:28
bool MouseControlTaken() const
const int32_t C4ClientIDUnknown
Definition: C4Client.h:24
C4PlayerType
Definition: C4Constants.h:152
C4RoundResults & RoundResults
Definition: C4Game.h:75
C4Network2ResList ResList
Definition: C4Network2.h:113
int32_t GetIdentification()
Definition: C4Menu.cpp:615
const int32_t TEAMID_New
Definition: C4Teams.h:27
int32_t Surrendered
Definition: C4Player.h:86
C4ObjectList Crew
Definition: C4Player.h:127
int32_t Eliminated
Definition: C4Player.h:85
C4Value SoundModifier
Definition: C4Player.h:142
void PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:481
C4SPlrStart PlrStart[C4S_MaxPlayer]
Definition: C4Scenario.h:233
C4Reloc Reloc
Definition: C4Reloc.cpp:22
void PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
Definition: C4Player.cpp:531
int32_t CurrentScore
Definition: C4Player.h:118
void SetMinZoom(C4Fixed zoom, bool no_increase, bool no_decrease)
Definition: C4Player.cpp:1827
bool ActivateMenuMain()
Definition: C4Player.cpp:1764
bool ScenarioInit()
Definition: C4Player.cpp:605
bool PositionTaken(int iPosition) const
int32_t Wealth
Definition: C4Player.h:117
bool IsActive()
Definition: C4Menu.cpp:483
int32_t CrewMember
Definition: C4Def.h:114
void CheckElimination()
Definition: C4Player.cpp:1172
void Evaluate()
Definition: C4Player.cpp:791
void DoTeamSelection(int32_t idTeam)
Definition: C4Player.cpp:1254
bool IsScenarioInitDesired() const
Definition: C4PlayerInfo.h:179
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:281
static C4ControlPlayerAction * InitPlayerControl(const C4Player *source, const C4PlayerControlAssignmentSet *ctrl_set=nullptr)
Definition: C4Control.cpp:623
int32_t ZoomLimitMinWdt
Definition: C4Player.h:114
void SetGlobalModifier(C4SoundModifier *new_modifier, int32_t player_index)
C4IDList ReadyBase
Definition: C4Scenario.h:146
virtual bool isDeserializer()
Definition: StdCompiler.h:63
int32_t AtClient
Definition: C4Player.h:99
bool NoEliminationCheck
Definition: C4Player.h:103
int32_t GetHeight() const
int32_t ID
Definition: C4Player.h:89
bool Save(C4Group &hGroup, bool fSavegame, bool fStoreTiny, C4DefList *pDefs)
int32_t FinalScore
Definition: C4InfoCore.h:72
uint32_t GetColor() const
Definition: C4PlayerInfo.h:156
int32_t ZoomLimitMaxHgt
Definition: C4Player.h:114
bool C4Group_MoveItem(const char *szSource, const char *szTarget1, bool fNoSort)
Definition: C4Group.cpp:144
int32_t StartupPlayerCount
Definition: C4Game.h:111
void RemovePlayerByID(int32_t iID)
Definition: C4Teams.cpp:95
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
C4IDList ReadyVehic
Definition: C4Scenario.h:147
const char * GetName() const
Definition: C4Player.h:153
C4Fixed ZoomLimitMinVal
Definition: C4Player.h:115
void EvaluateLeague(bool fDisconnected, bool fWon)
Definition: C4Player.cpp:1519
float GetZoomByViewRange(int32_t size_x, int32_t size_y) const
Definition: C4Viewport.cpp:467
void UnSelect()
Definition: C4Object.cpp:4334
C4Real ViewY
Definition: C4Player.h:108
int32_t TotalScore
Definition: C4InfoCore.h:90
#define C4CFN_BigIcon
Definition: C4Components.h:111
StdCopyStrBuf nInfo
Definition: C4Object.h:168
void CountControl(ControlType eType, int32_t iID, int32_t iCntAdd=1)
Definition: C4Player.cpp:1635
#define PSF_OnWealthChanged
Definition: C4GameScript.h:151
void DoExperience(int32_t change)
Definition: C4Object.cpp:1225
#define C4CFN_TempPlayer
Definition: C4Components.h:162
StdCopyStrBuf ControlSetName
Definition: C4Player.h:93
void SetTeamHostility()
Definition: C4Player.cpp:919
bool IsElement(C4ObjectInfo *pInfo)
std::unique_ptr< C4MessageBoard > MessageBoard
int32_t GetMapZoom() const
bool DoScore(int32_t iChange)
Definition: C4Player.cpp:1346
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:819
void Execute()
Definition: C4Menu.cpp:906
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:524
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
Definition: C4Object.cpp:4020
void ResetCursorView(bool immediate_position=false)
Definition: C4Player.cpp:784
int32_t GetInGameNumber() const
Definition: C4PlayerInfo.h:192
bool SetIDCount(C4ID c_id, int32_t iCount, bool fAddNewID=false)
Definition: stub-handle.cpp:68
#define PSF_PreInitializePlayer
Definition: C4GameScript.h:42
bool LeagueEvaluated
Definition: C4Player.h:102
void UpdateLight()
Definition: C4Object.cpp:4043
void ExecuteControl()
Definition: C4Player.cpp:1058
const int C4P_MaxPosition
Definition: C4Constants.h:63
C4SGame Game
Definition: C4Scenario.h:232
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
C4Player * Next
Definition: C4Player.h:144
void EvaluatePlayer(C4Player *pPlr)
float fixtof(const C4Fixed &x)
Definition: C4Real.h:257
void InitControl()
Definition: C4Player.cpp:1397
C4Fixed ZoomLimitMaxVal
Definition: C4Player.h:115
void Surrender()
Definition: C4Player.cpp:832
C4ObjectInfoList CrewInfoList
Definition: C4Player.h:126
int32_t InitialScore
Definition: C4Player.h:118
void ClearGraphs()
Definition: C4Player.cpp:1618
#define C4FLS_Player
Definition: C4Components.h:193
void Clear()
Definition: C4Menu.cpp:272
bool isLeague() const
bool DeleteItem(size_t iIndex)
Definition: C4IDList.cpp:423
int32_t RetireDelay
Definition: C4Player.h:97
int32_t Position[2]
Definition: C4Scenario.h:143
virtual void Default()
void AdjustCursorCommand()
Definition: C4Player.cpp:1063
bool IsContained(const C4Object *pObj) const
const int32_t C4PVM_Target
Definition: C4Player.h:34
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:456
int32_t Experience
Definition: C4InfoCore.h:44
void PlaceReadyVehic(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:556
size_t getLength() const
Definition: StdBuf.h:453
void SetTitle(const char *szNewTitle)
C4Object * ViewTarget
Definition: C4Player.h:110
void SetMinZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease)
Definition: C4Player.cpp:1807
C4DefList Definitions
Definition: C4Globals.cpp:49
bool Save()
Definition: C4Player.cpp:417
C4IDList ReadyMaterial
Definition: C4Scenario.h:148
int32_t GetID() const
Definition: C4PlayerInfo.h:197
C4MessageBoardQuery * pNext
C4PlayerType GetType() const
Definition: C4PlayerInfo.h:155
const int32_t C4PVM_Cursor
Definition: C4Player.h:33
bool Sort(const char *szSortList)
Definition: C4Group.cpp:1963
void RemoveCrewObjects()
Definition: C4Player.cpp:1275
bool IsRuntimeJoinTeamChoice() const
Definition: C4Teams.h:174
C4Rect Entrance
Definition: C4Def.h:107
bool SetWealth(int32_t val)
Definition: C4Player.cpp:745
const char * AtTempPath(const char *szFilename)
Definition: C4Config.cpp:538
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
int32_t ZoomHgt
Definition: C4Player.h:114
int32_t Hgt
Definition: C4Rect.h:32
T Abs(T val)
Definition: Standard.h:44
bool IsJoin2TeamAllowed(int32_t idTeam, C4PlayerType plrType)
Definition: C4Teams.cpp:535
C4SHead Head
Definition: C4Scenario.h:230
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:602
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:654
bool fFogOfWar
Definition: C4Player.h:113
#define PSF_InitializePlayer
Definition: C4GameScript.h:40
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:333
int igOffY
Definition: C4Player.cpp:1452
void Strip(C4DefList &rDefs)
C4ObjectPtr ViewCursor
Definition: C4Player.h:132
bool ItemExists(const char *szItemName)
Definition: StdFile.h:75
bool GainScenarioAchievement(const char *achievement_id, int32_t value, const char *scen_name_override=nullptr)
Definition: C4Player.cpp:1910
C4GamePadControl * pGamePadControl
Definition: C4Application.h:43
int32_t Rounds
Definition: C4InfoCore.h:91
C4ObjectInfo * New(C4ID n_id, C4DefList *pDefs)
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
void DefaultRuntimeData()
Definition: C4Player.cpp:1210
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
C4IDList BaseMaterial
Definition: C4Player.h:122
bool FindSolidGround(int32_t &rx, int32_t &ry, int32_t width)
const char * GetCommand() const
Definition: C4Menu.h:113
std::unique_ptr< C4Network2Stats > pNetworkStatistics
Definition: C4Game.h:97
uint32_t DWORD
bool ObjectInCrew(C4Object *tobj)
Definition: C4Player.cpp:92
const char * GetFilePath() const
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
const int C4FCT_Full
Definition: C4FacetEx.h:26
#define PSF_InitializeScriptPlayer
Definition: C4GameScript.h:41
C4ObjectInfo * GetIdle(C4ID c_id, C4DefList &rDefs)
int32_t Controller
Definition: C4Object.h:111
void Copy()
Definition: StdBuf.h:475
C4Facet GetPhase(int iPhaseX=0, int iPhaseY=0)
Definition: C4Facet.cpp:59
int32_t Duration
Definition: C4InfoCore.h:70
int32_t Level
Definition: C4InfoCore.h:74
C4ScenarioParameters Achievements
Definition: C4InfoCore.h:109
C4Fixed ZoomVal
Definition: C4Player.h:115
class C4MessageBoardQuery * pMsgBoardQuery
Definition: C4Player.h:138
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets
Definition: C4Game.h:95
int32_t Bonus
Definition: C4InfoCore.h:73
int32_t Evaluate()
Definition: C4Scenario.cpp:50
int32_t ActionCount
Definition: C4Player.h:149
C4Application Application
Definition: C4Globals.cpp:44
static C4Facet GetIconFacet(Icons icoIconIndex)
void SetJoined(int32_t iNumber)
bool ActivateMain(int32_t iPlayer)
Definition: C4MainMenu.cpp:567
bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange)
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
Definition: C4Real.cpp:9033
C4Object * CreateInfoObject(C4ObjectInfo *cinf, int32_t owner, int32_t tx=50, int32_t ty=50)
Definition: C4Game.cpp:1090
int32_t GetWidth() const
bool Init(int32_t iNumber, int32_t iAtClient, const char *szAtClientName, const char *szFilename, bool fScenarioInit, class C4PlayerInfo *pInfo, C4ValueNumbers *)
Definition: C4Player.cpp:259
void ZoomToViewports(bool direct, bool no_increase=false, bool no_decrease=false)
Definition: C4Player.cpp:1839
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
Definition: C4Game.cpp:1076
void SetSoundModifier(C4PropList *new_modifier)
Definition: C4Player.cpp:1926
bool MarkMessageBoardQueryAnswered(C4Object *pForObj)
Definition: C4Player.cpp:1690
const int32_t C4NetResMaxBigicon
Definition: C4Network2Res.h:36
void PlaceReadyMaterial(int32_t tx1, int32_t tx2, int32_t ty, C4Object *FirstBase)
Definition: C4Player.cpp:577
void SetMaxZoom(C4Fixed zoom, bool no_increase, bool no_decrease)
Definition: C4Player.cpp:1833
void SetColorDw(DWORD dwClr)
virtual bool Remove(C4Object *pObj)
C4IDList BaseProduction
Definition: C4Player.h:123
C4GameObjects Objects
Definition: C4Globals.cpp:48
StdCopyStrBuf Title
Definition: C4InfoCore.h:68
const int32_t C4ClientIDHost
Definition: C4Client.h:25
void SetValue(const char *id, int32_t value, bool only_if_larger)
int32_t GetIndex(C4ID c_id) const
Definition: C4IDList.cpp:202
const C4Real Fix0
Definition: C4Real.h:312
bool SetHostility(int32_t iOpponent, int32_t iHostility, bool fSilent=false)
Definition: C4Player.cpp:842
bool LocalSync()
Definition: C4Player.cpp:1534
bool GBackSolid(int32_t x, int32_t y)
Definition: C4Landscape.h:232
void ExecBaseProduction()
Definition: C4Player.cpp:1157
bool RemoveMessageBoardQuery(C4Object *pForObj)
Definition: C4Player.cpp:1677
int32_t GetIndexedPlayer(int32_t iIndex) const
Definition: C4Teams.h:76
bool LocalControl
Definition: C4Player.h:101
C4IDList BaseMaterial
Definition: C4Scenario.h:150
C4Real ViewX
Definition: C4Player.h:108
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277
HostilitySet Hostility
Definition: C4Player.h:120
C4RoundResult LastRound
Definition: C4InfoCore.h:93
void SetWinner()
Definition: C4PlayerInfo.h:204
C4PlayerType GetType() const
Definition: C4Player.cpp:1730
C4PropList * getPropList() const
Definition: C4Value.h:116